TMar

I want to input a command into the run command...is this possible and if so how

Thank you


Re: Visual C# General Input into command line

mwalts

You mean like going to the start menu in windows and selecting run

Sure, you use the Process class of the System.Diagnostics namespace

so, in your using statements
using System.Diagnostics;

now in your code

Process p1 = new Process();

p1.StartInfo.FileName = "the command you want to run";
p1.StartInfo.UseShellExecute = true;

p1.Start();

Have fun,

-mwalts




Re: Visual C# General Input into command line

Brazzle

If you are talking about command arguments like:

C:\> myapp.exe -r -l ...etc

then look at the main method. the string[] args parameter is any command-line arguments that the user inputs.

If not, see above.





Re: Visual C# General Input into command line

Tomas Scheel

mwalts wrote:
You mean like going to the start menu in windows and selecting run

Sure, you use the Process class of the System.Diagnostics namespace

so, in your using statements
using System.Diagnostics;

now in your code

Process p1 = new Process();

p1.StartInfo.FileName = "the command you want to run";
p1.StartInfo.UseShellExecute = true;

p1.Start();

Have fun,

-mwalts

You could just use:

Code Snippet

System.Diagnostics.Process.Start(string filePath, string Arguements);

if you just want to run a program the same way you do as through the run command. It wont give a shell like MWalts example though.

EXAMPLE:

Code Snippet

System.Diagnostics.Process.Start("c:\\windows\\system32\\shutdown.exe", "/r /f");