Page 1 of 1

Running DOS commands: This might be helpful to know.

Posted: Tue May 12, 2009 5:27 am
by bokkie
Guys,

I wanted to give some feedback about running DOS commands in IA. I've been fighting a particularly nasty problem on my XP machine at work where, under some conditions, DOS commands are not executing properly even though the syntax of the commands was valid. It then occurred to me that I was possibly taking the wrong approach. I've implemented a solution that is now running stable. What I implemented is this:

Use the Run Program statement as normal. In the Run Program textbox enter cmd.exe.

In the Command Line Parameters textbox enter /C copy A B /b /y replacing the copy... statement with the fully described DOS command you want to execute. You can get the full syntax of cmd.exe in a DOS window using cmd.exe /?. Notice the /C option. That waits for the command to finish which more or less complements the Wait For Program to Finish tickbox in the Run Program dialog displayed by IA.

I've found this to be much more stable. It does a similar function but I like it as I can keep the command and arguments glued together in one string. Your mileage will vary, as they say, but I've now fixed a vexing problem that's been bugging me for a while. 8)

What were the issues?

Posted: Tue May 12, 2009 7:49 am
by JeffTucker
Just curious why the straight up dos commands did not work. Did you find anything? What sort of commands were these? Service commands?

Posted: Tue May 12, 2009 7:58 am
by MichaelNesmith
Great post!

"Straightforward" DOS commands like copy are NOT executable files. They are commands that are parsed and run by the cmd.exe command line interpreter. Therefore, if you use them as your main command in Run Program, they will fail.

In other words, no copy.exe exists on your system...

Re: What were the issues?

Posted: Tue May 12, 2009 8:09 am
by bokkie
JeffTucker wrote:Just curious why the straight up dos commands did not work. Did you find anything? What sort of commands were these? Service commands?


Jeff, it was not just the copy that was failing but other commands. Even the humble and very basic date /t was failing. I've tested a few commands and they all now work 100% fine. What was interesting is that I built the three packages I'm using at home last night. I ran them on my work machine and they worked. When I built them however, that's when the problems became apparent again. I'm convinced my XP machine at work has something spooked on it which is causing build-and-run to behave abnormally unless I use cmd.exe. I got into the habit a while back of using it in my code but in the rush to complete my projects I forgot to keep that in the foreground of my head.

Edit: I also endorse Michael's comment about the difference between internal and exernal command usage.