Using system.diaglostics.Process in. NET can be used to invoke another command line or program.
Using System.Diagnostics;
If it's a DOS
Process.Start ("cmd.exe");
If it is another file
Process.Start ("absolute path + filename. exe");
------------------------------------
How do I call an external DOS program in C #?
Working with Process objects:
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="arj.exe" ;//需要启动的程序名
p.StartInfo.Arguments="-x sourceFile.Arj c:temp";//启动参数
p.Start();//启动
if(p.HasExisted)//判断是否运行结束
p.kill();
---------------------------------------------------------------------------------------- ------
<summary>
To start another application
</summary>
<param name= "File" > Application name </param>
<param name= "Workdirectory" > Application working directory </param>
<param name= "args" > Command line Arguments </param>
<param name= "style" > Window style </param>
public static bool StartProcess (string file,string workdirectory,string Args,processwindowstyle style)
{
Try
{
Process myprocess = new process ();
ProcessStartInfo startinfo = new ProcessStartInfo (File,args);
Startinfo.windowstyle = style;
Startinfo.workingdirectory = workdirectory;
Myprocess. StartInfo = StartInfo;
Myprocess. Startinfo.useshellexecute = false;
Myprocess. Start ();
return true;
}
catch (Exception E0)
{
MessageBox.Show ("Error starting application!") Reason: "+ E0." message);
}
return false;
}
String parms = "" + globalobject.getinstance (). UserID + "" + globalobject.getinstance (). UserPassword;
if (publicmethods.startprocess (Application.startuppath + @ "Uptooluptool.exe", Application.startuppath + "Uptool", Parms,processwindowstyle.normal))
{
Environment.exit (0);
}
---------------------------------------------------------------------------- ----------------