小弟不才能力有限,各位大大可否给出接口方法。就是当一个程序启动了,这个程序后台就会启动另外一个程序。

解决方案 »

  1.   

    方法有几种
    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:// 就可以打开记事本。