Page 1 of 1

[tip] Is it possible to run system command?

Posted: 23 Sep 2013 12:45
by pjj
I would like to use echo, but perhaps other commands might be handy, too. I tried

Code: Select all

MainApp.RunApp("echo", "test > test.txt", true, true, 0);
but didn't get even error message, hence the question. (If it's not possible now, please treat it as a feature request.)

Re: Is it possible to run system command?

Posted: 23 Sep 2013 16:16
by pjj
pjj wrote:(If it's not possible now, please treat it as a feature request.)
Actually, it would be cool to use CMD commands in scripts, but I just figured out how to solve my script-related problem without using echo. Please move it down on your to-do list 8)

Yes, Virginia, it is possible to run system command

Posted: 30 Sep 2013 13:53
by pjj
All you need to do is to add /c switch and enclose your argument list in parentheses, e.g.

Code: Select all

MainApp.RunApp("c:\\windows\\system32\\cmd.exe", "/c (echo Yes, you can call command line from a script!)", false, false);
If your argument is a file, of course you need to use double backslashes instead of single ones in its path, e.g.

Code: Select all

MainApp.RunApp("c:\\windows\\system32\\cmd.exe", "/c (del c:\\temp\\*.* /q)", false, false);
Please notice you can use variables as arguments, too:

Code: Select all

var filename = "readme.txt";
MainApp.RunApp("c:\\windows\\system32\\cmd.exe", "/c (del c:\\temp\\" + filename + ")", false, false);
Very truly yours,
Francis Pharcellus Church


(Would be helpful to add this to help file, I think.)