Is it possible to build a standalone Windows app using Visual Studio that runs Command-line commands and/or scripts ?
Asked
Active
Viewed 98 times
0
-
Possible duplicate of [C++ Executing DOS Commands](https://stackoverflow.com/questions/11564594/c-executing-dos-commands) – Mikhail Aug 07 '17 at 02:00
-
To what end? How would your proposed app be different from cmd.exe? – Harry Johnston Aug 07 '17 at 03:54
-
I am looking to make a GUI app that would run a command and/or script when a button is pressed. – Ahmad Taj Aug 08 '17 at 01:57
1 Answers
0
Yes, you can do this, and you can do it in multiple languages too.
For C#, according to this question, you can run:
string strCmdText;
strCmdText= "p4.exe jobs -e";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
In a nutshell, you can call the .NET API (see the Start documentation here ), and start an instance of CMD.exe (or bash or whatever else you want to call) and send it a command. You can get information on what the result of the script's run was using the properties and methods of the Process class.

Robert Columbia
- 6,313
- 15
- 32
- 40
-
Running a command line via CMD needs to start with `/c` or `/k` and in general requires double quotes around the command line to avoid mangling quotes if the first argument in the command line is quoted and it's not the only quoted argument, e.g. `"/c \"\"C:\\Program Files\\Some App\\p4.exe\" jobs -e \"Some Arg\"\""`. – Eryk Sun Aug 07 '17 at 02:35
-
I mean is it possible to build a Windows app or widget with a GUI that will run a command, such as move files from one directory to another, by pressing a button. – Ahmad Taj Aug 08 '17 at 02:03