PDA

View Full Version : Launch Command Line


critter
05-08-2006, 11:58 AM
How can you launch a command line or DOS prompt?
File.Run("c:\windows\system32\cmd.exe", "", "", SW_SHOWNORMAL, false);
Does not seem to work.

longedge
05-08-2006, 04:01 PM
This works for me in a button on click -

result = File.Run("cmd.exe", "", "", SW_SHOWNORMAL, false);

p.s. - you have to escape backslashes i.e. -

File.Run("c:\\windows\\system32\\cmd.exe", "", "", SW_SHOWNORMAL, false);

critter
05-09-2006, 09:47 AM
Thanks! Works great. It's always something simple.
Now for another question. Can you launch a specific command, such as "ipconfig" from the command line and do all of this with a single button click? One button click: open command line, run ipconfig.

longedge
05-09-2006, 11:34 AM
Can you launch a specific command, such as "ipconfig" from the command line and do all of this with a single button click? One button click: open command line, run ipconfig.

Yes certainly, my own preference is to make a batch file and then run that. One of the reason I use this method is because I could never succesfully incorporate command line parameters - the correct syntax always eludes me :). If I can find a moment later, I'll post an example.

critter
05-09-2006, 11:36 AM
Thanks!!! That would be awesome and greatly appreciated.

longedge
05-09-2006, 12:33 PM
OK try this - it has 3 buttons each runs a different .bat and I've put a 'pause' at the end to stop the dos window closing.

You could incorporate a pipe command to direct output from the batch file to another text file and then after a 'wait' load the resultant text file into a paragraph object to keep it all inside the AMS app.