-
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?
This restarts the computer A:
HTML Code:
Runtime.getRuntime().exec("shutdown " + receivedCommand + " /t " + delay + " /c \"" + comment + "\"");
This allows the user of the computer A to abort the shutdown if necessary:
HTML Code:
Runtime.getRuntime().exec("shutdown /a");
OS: Win Xp
JRE 5.0 Update 6
Thanks for any help.
-
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?
-
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...
-
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.
Last edited by hexaplus; 03-20-2006 at 07:26 PM.
-
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.
Similar Threads
-
By Arjuna in forum Database
Replies: 2
Last Post: 07-25-2007, 03:22 AM
-
By alcdotcom in forum Java
Replies: 4
Last Post: 09-29-2005, 08:09 PM
-
By jase_dukerider in forum C++
Replies: 2
Last Post: 04-14-2005, 07:48 PM
-
Replies: 146
Last Post: 08-12-2002, 10:40 PM
-
By Paul in forum Database
Replies: 0
Last Post: 08-22-2000, 10:54 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks