What is the difference between running a program from the NT command line versus Runtime.exec()?

Darin Hawley

To get a program to run from Runtime.exec() like it was running from the command line, you need to tell Runtime.exec() to use your command shell (cmd.exe). In addition, for some reason, there is this little switch on the NT shell which seems to be required, though I'm not sure why. The following demonstrates this usage:

String[] command = { 
  "C:winntsystem32cmd.exe", "/y", "/c",
  "C:dirprogram.exe", "arg1", "arg2"
};
Runtime.getRuntime().exec(command);
The /y will "Disable extensions to the Windows NT version of CMD.EXE". Enter cmd /? to see more about the extensions.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact