0

Is it possible to build a standalone Windows app using Visual Studio that runs Command-line commands and/or scripts ?

3
  • Possible duplicate of C++ Executing DOS Commands Commented Aug 7, 2017 at 2:00
  • To what end? How would your proposed app be different from cmd.exe? Commented Aug 7, 2017 at 3:54
  • I am looking to make a GUI app that would run a command and/or script when a button is pressed. Commented Aug 8, 2017 at 1:57

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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\"\"".
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.