Run a program that accepts command line options

How to execute a program that accepts command line parameters in C #?

+4
source share
4 answers

Use the Start class method.

Starts a process resource by specifying the application name 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"); 
+10
source

Class ProcessStartInfo

ProcessStartInfo is used with the Process component. when you start a process using the Process class, you have access to the process information in addition to what is available when you join.

 ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); startInfo.Arguments = "www.northwindtraders.com"; Process process = Process.Start(startInfo); 
+5
source
 ProcessStartInfo p = new ProcessStartInfo(@"prg_name", @"args"); Process process = Process.Start(p); 
+1
source

try it

  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

+1
source

Source: https://habr.com/ru/post/1411715/


All Articles