If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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?

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.

Can't work with System32

Originally Posted by hexaplus

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...

Can't work with System32

Originally Posted by hexaplus

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.