Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst CreateProcess: error=2  RSS feed

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 I use batch commands.but result is the following exception..

" CreateProcess: shut.bat 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

Posts: 4179
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.
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!