• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.io.IOException: CreateProcess: error=2  RSS feed

 
Dilanka Muthukumarana
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!