PDA

View Full Version : Ending a running Process


cooldude1561
06-18-2007, 09:42 PM
hi, i am a basic java programmer and i need help to make a workaround for the source program.

i need help writing a code that could end hl2.exe and then go to a link.

if any one can help i will greatly appreciate it, thanks

javabits
06-19-2007, 12:04 AM
Not a lot of options here, and also there are os dependencies, you didn't state you were on windows but I'll assume that because you mentioned a .exe. If you're on windows you will need to call an external program using java.lang.Runtime.exec (you'll need another program to kill the process). You can find one here http://www.beyondlogic.org/solutions/processutil/processutil.htm


Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("process -k hl2.exe");
int exitVal = proc.exitValue();
System.out.println("Process exitValue: " + exitVal);


As for going to a link you can probably do the same by changing the commandline to exec to something like
C:\Program Files\Internet Explorer\iexplore.exe http://www.yahoo.com

You may need to use one of the other versions of exec that takes an array of strings or escape out the spaces in the path.

semper fi...

cooldude1561
06-19-2007, 12:27 AM
well heres the thing, im not sure if you are aware of a program called "steam" which allows you to play many online games. recently they had an update which doesnt allow you to redirect people to a new server. so what we need to do is find a code that will allow you to "crash" steam and then reopen it to the new server. i decided java is probably the best way to go about doing this....

o yeah we use windows XP