| Author |
java.io.IOException: CreateProcess: error=2
|
Dilanka Muthukumarana
Greenhorn
Joined: Mar 28, 2009
Posts: 5
|
|
hey all..
I tried to run java code to access shut.bat file to shutdown remote computer.so I use batch commands.but result is the following exception..
"java.io.IOException: CreateProcess: shut.bat 127.0.0.1 Dilanka keepintouch error=2" in this file username is dilanka and password is keepintouch.. this is ma code sample:
I have already included "shut.bat" , psshutdown.exe and shut.class files in the suitable folder..
please help me to run this program.
shut.bat file
psshutdown.exe -k -u %2 -p %3 -t 5 \\%1
shut.java
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3036
|
|
The rest of the error message for that "error=2" error is "No such file or directory". You are trying to run a bat file, you have one (possibly 2) likely errors. At very least, you are treating the Java Runtime.exec() method as if it was a Windows command line. It is not, and so should not be treated as one. Read this article: When Runtime.exec() won't. It will help. Make sure you fully implement all of its suggestions.
Another likely error could be that the path of the bat file isn't where you expect it to be. Make sure you know the 'working' path that Runtime.exec() is using, or use the version of the exec() method that provides an option for you to define the working directory, just to be sure you know exactly where the bat file should be located to be found.
|
Steve
|
 |
 |
|
|
subject: java.io.IOException: CreateProcess: error=2
|
|
|