Running a command from a jar file
Hi, guys. I hope you can help me. I've already done some search and didn't find a satisfying answer. I know, its probably a very stupid problem, but I just don't know what to do.
So, here it is:
I've got an application which is silently running on a computer A. I've got also another application on a computer B. Using this application I can remotely restart/log of/shutdown computer A. The action is performed by shutdown.exe + parameters which I specify on the computer B. EVERYTHING WORKS PERFECTLY as long as I don't create *.jar files. Running from *.jar archives everything works up to the point when the shutdown command should be executed. I always end up with java.io.IOException: CreateProcess: shutdown.exe /r /t 60 /c "comment" error=2.
I also know that Runtime.exec() is NOT a command line, so what should I do to make it run directly from *.jar? :SICK:
This restarts the computer A:
Runtime.getRuntime().exec("shutdown " + receivedCommand + " /t " + delay + " /c \"" + comment + "\"");
This allows the user of the computer A to abort the shutdown if necessary:
Runtime.getRuntime().exec("shutdown /a");
OS: Win Xp
JRE 5.0 Update 6
Thanks for any help.
[1271 byte] By [
petmal] at [2007-11-11 8:16:04]

# 1 Re: Running a command from a jar file
Couple of things to try:
Are you sure that the file is running under the right permissions? Try running your program sudo or as admin. My thoughts being and I'm guessing maybe you java.exe or javaw.exe is running at higher permission then you .jar file. It seems to me like your getting held up when you try and create a new thread try exec-ing a different low level command.
And is your Main-Class manifest attribute set correctly?
# 2 Re: Running a command from a jar file
Couple of things to try:
Are you sure that the file is running under the right permissions? Try running your program sudo or as admin. My thoughts being and I'm guessing maybe you java.exe or javaw.exe is running at higher permission then you .jar file. It seems to me like your getting held up when you try and create a new thread try exec-ing a different low level command.
And is your Main-Class manifest attribute set correctly?
It is probably a security issue. I can execute anything as long as it is out of the System32 directory. When I take (copy) shutdown.exe out of System32 it works perfectly. A possible solution is to put *.jar into System32, unfortunately, it's then impossible to run the program at all. Windows just don't want anything to mess with System32, even if I'm logged as an Administrator... :SICK:
petmal at 2007-11-11 22:36:54 >

# 4 Re: Running a command from a jar file
Sorry I'm more of a unix guy can, have you tried specifying the fully qualified path? I'm hoping you succeed because I'm going to be doing the same thing in about a week.
Yes. If it's not invoked from the command line, my Windows just doesn't want to run anything from the system32 directory. I can make a *.bat to run the program, but then end up with a console window hanging on the screen.
petmal at 2007-11-11 22:38:58 >
