[急]WPF中一个程序中如何启动另外一个程序 小弟不才能力有限,各位大大可否给出接口方法。就是当一个程序启动了,这个程序后台就会启动另外一个程序。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 方法有几种1.程序中打开System.Diagnostics.Process.Start(程序路径);例子public void OpenRunPark() { try { //string path = @"E:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"; //string path = @"E:\Program Files\TTPlayer\TTPlayer.exe";// string path = "C:\\Program Files\\Ray\\Xpert-Central_live\\Main\\posisent.exe";// System.Diagnostics.Process.Start(path); System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); //string path = "start /D \"E:\\Program Files\\TTPlayer\\\" TTPlayer.exe"; string path = "start /D \"C:\\Program Files\\Ray\\Xpert-Central_live\\Main\\\" posisent.exe"; //"E:\Program Files\TTPlayer\TTPlayer.exe" //"C:\Program Files\Ray\Xpert-Central_live\Main\posisent.exe" p.StandardInput.WriteLine(path); p.Close(); p.Dispose(); StreamWriter wt = File.AppendText(@"D:\xPertErrLog.txt"); wt.Write("打开应用程序成功!路径为"+path); wt.WriteLine(File.GetLastWriteTime(@"D:\xPertErrLog.txt")); wt.Close(); } catch { StreamWriter wt = File.AppendText(@"D:\xPertErrLog.txt"); wt.Write("打开应用程序失败!请检查打开路径是否出错! "); wt.WriteLine(File.GetLastWriteTime(@"D:\xPertErrLog.txt")); wt.Close(); } }2.调用CMD打开start /D "C:\Program Files\Ray\Xpert-Central\Main\" posisent.exe Dim p As New System.Diagnostics.Process p.StartInfo.FileName = "cmd.exe" p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardInput = True p.StartInfo.RedirectStandardOutput = True p.StartInfo.RedirectStandardError = True p.StartInfo.CreateNoWindow = True p.Start() Dim s As String = "start /D ""C:\Program Files\Ray\Xpert-Central\Main\"" posisent.exe" p.StandardInput.WriteLine(s) p.Close() p.Dispose()3.注册后用协议打开将下面的文件存储xx.regCode Snippet REGEDIT4[HKEY_CLASSES_ROOT\mxh]"@"="URL:mxh Protocol" @="URL:mxh Protocol""URL Protocol"="" [HKEY_CLASSES_ROOT\mxh\Shell] [HKEY_CLASSES_ROOT\mxh\Shell\Open] [HKEY_CLASSES_ROOT\mxh\Shell\Open\Command]@="C:\\windows\\system32\\notepad.exe \"%1\"" 然后注册,在浏览器里面输入:mxh:// 就可以打开记事本。 关于二进制编码问题。 字符显示问题 有偿 求助*.rs脚本文件转文本文件 修改了 c# windows service 后台代码,,要重新安装或者重新启动吗 C#中关于MD5还有Kerberos public key方面的问题! C#如何取得数据编辑框中的图插入word 不太理解下面的代码,希望大侠过来讲解下,谢谢 如何在.NET中定义一个变量用于存储多次运行一个页面进行的运算 请教freesoul_ms([微软] 最后的白鸟) :在C#中如何实现对象事件转移 C#送分小问题。 c#中如何让两个combobox联系起来??急!! 先学javascript还是C#
1.程序中打开
System.Diagnostics.Process.Start(程序路径);
例子public void OpenRunPark()
{
try
{
//string path = @"E:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe";
//string path = @"E:\Program Files\TTPlayer\TTPlayer.exe";
// string path = "C:\\Program Files\\Ray\\Xpert-Central_live\\Main\\posisent.exe";
// System.Diagnostics.Process.Start(path); System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
//string path = "start /D \"E:\\Program Files\\TTPlayer\\\" TTPlayer.exe";
string path = "start /D \"C:\\Program Files\\Ray\\Xpert-Central_live\\Main\\\" posisent.exe";
//"E:\Program Files\TTPlayer\TTPlayer.exe"
//"C:\Program Files\Ray\Xpert-Central_live\Main\posisent.exe"
p.StandardInput.WriteLine(path);
p.Close();
p.Dispose(); StreamWriter wt = File.AppendText(@"D:\xPertErrLog.txt");
wt.Write("打开应用程序成功!路径为"+path);
wt.WriteLine(File.GetLastWriteTime(@"D:\xPertErrLog.txt"));
wt.Close();
}
catch
{
StreamWriter wt = File.AppendText(@"D:\xPertErrLog.txt");
wt.Write("打开应用程序失败!请检查打开路径是否出错! ");
wt.WriteLine(File.GetLastWriteTime(@"D:\xPertErrLog.txt"));
wt.Close();
}
}2.调用CMD打开start /D "C:\Program Files\Ray\Xpert-Central\Main\" posisent.exe Dim p As New System.Diagnostics.Process
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.Start()
Dim s As String = "start /D ""C:\Program Files\Ray\Xpert-Central\Main\"" posisent.exe"
p.StandardInput.WriteLine(s)
p.Close()
p.Dispose()3.注册后用协议打开
将下面的文件存储xx.reg
Code Snippet
REGEDIT4[HKEY_CLASSES_ROOT\mxh]
"@"="URL:mxh Protocol"
@="URL:mxh Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\mxh\Shell]
[HKEY_CLASSES_ROOT\mxh\Shell\Open]
[HKEY_CLASSES_ROOT\mxh\Shell\Open\Command]
@="C:\\windows\\system32\\notepad.exe \"%1\""
然后注册,在浏览器里面输入:mxh:// 就可以打开记事本。