通过Process调用桌面程序
2012-02-02 14:47
405 查看
通过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(null, null);
25
26 }
27
28 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
29 {
30 Application.Exit();
31 }
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(null, null);
25
26 }
27
28 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
29 {
30 Application.Exit();
31 }
相关文章推荐
- QProcess与外部程序的调用(可以通过设置管道来交互)
- 通过JAVA调用命令行程序
- 如何在PHP中通过ADO调用Asscess数据库和COM程序
- SilverLight浏览器交互之:Html页面通过Javascript调用SilverLight程序内方法(附源码)
- Lua通过COM调用外部程序excel及调用windows api
- 在android中通过java层程序调用命令行的一些备注
- VC++通过COM调用Matlab程序
- hiveapi通过Java程序调用
- Java通过JNI调用C++程序
- 如何在PHP中通过ADO调用Asscess数据库和COM程序
- 通过程序在桌面添加快捷方式
- QProcess调用外部程序:QProcess::start与QProcess::execute
- c#通过纯代码创建桌面快捷方式、创建程序菜单项、将网页添加到收藏夹
- 标准C/C++程序通过gSOAP调用WebService
- GDI+实现的图片相互转换程序,可以通过命令行参数来调用
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- idea中通过java程序直接调用python文件
- Java程序通过weka调用libsvm和liblinear的方法
- C# 中通过程序调用命令行Ping 网络的实现
- C# 调用其它程序 Process.Start 方法