RnR
RnR

Reputation: 209

Execute a Program Which Accept Command Line Parameters

How to Execute a Program Which accepts Command Line Parameters in c#?

Upvotes: 5

Views: 18970

Answers (4)

Ravi Gadag
Ravi Gadag

Reputation: 15851

ProcessStartInfo Class

ProcessStartInfo is used together with the Process component. When you start a process using the Process class, you have access to process information in addition to that available when attaching to a running process.

ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.Arguments = "www.northwindtraders.com";
  Process process = Process.Start(startInfo);

Upvotes: 6

Vipin Nair
Vipin Nair

Reputation: 515

Try this

   ProcessStartInfo startInfo = new ProcessStartInfo();        
   startInfo.FileName = "C:\etc\Program Files\ProgramFolder\Program.exe";
   startInfo.Arguments = "C:\etc\desktop\file.spp C\etc\desktop\file.txt";
   Process.Start(startInfo);

Or you can try the link http://msdn.microsoft.com/en-us/library/aa288457%28v=vs.71%29.aspx

Upvotes: 2

juergen d
juergen d

Reputation: 204746

ProcessStartInfo p = new ProcessStartInfo(@"prg_name", @"args");
Process process = Process.Start(p);

Upvotes: 1

sloth
sloth

Reputation: 101032

Use the Start method of the Process class.

Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.

Example:

Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");

Upvotes: 11

Related Questions