现在的位置: 首页 > 综合 > 正文

通过Process调用桌面程序

2013年06月18日 ⁄ 综合 ⁄ 共 1250字 ⁄ 字号 评论关闭

通过Process调用桌面程序

View Code

 1 private void Form1_Load(object sender, EventArgs e)
 2         {
 3             string userid = "admin";
 4             string password = "00";
 5             string[] cmd = new string[] { @"cd E:\Project\DotNet\bin\Debug""PhotoMan.exe $StartFromEIP$ " + userid + " " + assword };
 6 
 7             Process p = new Process();
 8             p.StartInfo.FileName = "cmd.exe";
 9             p.StartInfo.UseShellExecute = false;
10             p.StartInfo.RedirectStandardInput = true;
11             p.StartInfo.RedirectStandardOutput = true;
12             p.StartInfo.RedirectStandardError = true;
13             p.StartInfo.CreateNoWindow = true;
14             p.Start();
15             p.StandardInput.AutoFlush = true;
16             for (int i = 0; i < cmd.Length; i++)
17             {
18                 p.StandardInput.WriteLine(cmd[i].ToString());
19             }
20             p.StandardInput.WriteLine("exit");
21             string strRst = p.StandardOutput.ReadToEnd();
22             p.WaitForExit();
23             p.Close();
24             Form1_FormClosed(nullnull);
25 
26         }
27 
28         private void Form1_FormClosed(object sender, FormClosedEventArgs e)
29         {
30             Application.Exit();
31         }

 

 

抱歉!评论已关闭.