如何在.net应用程序中执行其他程序?
1.
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c"+ "notepad.exe";
//p.StartInfo.Arguments = "/c"+"C:\\\"Documents and Settings\"\\Test\\Test.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.Start();
if (waitForExit)
p.WaitForExit();

2.
用WinExec
[DllImport("kernel32.dll")]
public static extern int WinExec(string exeName, int operType);
public void StartProgram()
{
WinExec("....name.exe",5);
}
3.
用ShellExecute
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c"+ "notepad.exe";
//p.StartInfo.Arguments = "/c"+"C:\\\"Documents and Settings\"\\Test\\Test.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.Start();
if (waitForExit)
p.WaitForExit();
2.
用WinExec
[DllImport("kernel32.dll")]
public static extern int WinExec(string exeName, int operType);
public void StartProgram()
{
WinExec("....name.exe",5);
}
3.
用ShellExecute

浙公网安备 33010602011771号