可执行程序保存在触控机上。现在想调用。网上有很多方法,我照葫芦画瓢的使用。调用不了。
using System.Diagnostics;   Process process = new Process();
 process.StartInfo.FileName =  "重启.exe";
 process.StartInfo.Arguments = "";
 process.Start();后来,在网上找了段程序:
 System.Diagnostics.Process process = new System.Diagnostics.Process();
   Process process = new Process();
   process.StartInfo.FileName =  "re.exe";
   process.StartInfo.Arguments = "";
            try
               {
                 process.Start();
               }
               catch (System.ComponentModel.Win32Exception e)
               {
                   Console.WriteLine("系统找不到指定的程序文件。\r{0}", e);
                   return;
               }   程序会走到Console.WriteLine("系统找不到指定的程序文件。\r{0}", e);
接着触控机屏幕上会显示:
System.ComponentModel.Win32Exception:  Win32Exception
      位于  System.Diagnostics.Process.StartWithShellExecuteEx() 
      位于   System.Diagnostics.Process.Start() 
      位于    System.Diagnostics.Process.Start(ProcessStartInfo   startInfo) 
      位于    System.Diagnostics.Process.Start(String   fileName) 
      位于    WindowsApplication1.DataBaseAdmin.saveFileDialog1_FileOk(Object   sender,   CancelEventArgs   e)   in   \\192.168.15.102\tufn\tjlog\windowsapplication1\databaseadmin.cs:line   96 
      位于   System.Windows.Forms.FileDialog.OnFileOk(CancelEventArgs   e) 
     位于   System.Windows.Forms.FileDialog.DoFileOk(IntPtr   lpOFN) 
跟上面的信息差不多的一些东西。
不知道是不是路径的问题。比如,“重启.exe”保存在触控机 “我的设备(开机后显示桌面上的)-ResidentFlash(盘)-GUI(文件夹)”。路径该如何写。触控机是WINCE5.0的系统。

解决方案 »

  1.   

     process.StartInfo.FileName = "re.exe";换成具体路径试试
      

  2.   

            private void 农历繁体ToolStripMenuItem_Click(object sender, EventArgs e)
            { System.Diagnostics.Process.Start("萬年曆繁體.exe"); }
      

  3.   

    private void 农历繁体ToolStripMenuItem_Click(object sender, EventArgs e)
            { this.BeginInvoke(new Action(() => System.Diagnostics.Process.Start("萬年曆繁體.exe"))); }
      

  4.   

    肯定是你路径的问题,
    process.StartInfo.FileName = "re.exe";
    换成路径.
      

  5.   

    process.StartInfo.FileName = "re.exe";你这是相对路径,看看文件存在吗,不行就换成绝对路径
      

  6.   

    System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = Application.StartupPath + "\\re.exe";//可执行程序在目录下
                p.StartInfo.Arguments = "参数1 参数2";//传参用
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                p.Start();
      

  7.   

    确实是路径问题。
                string CurrentPath;       
                string filepath;
                System.Diagnostics.Process p = new Process();
                CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);              
                filepath = (CurrentPath + "\\re.exe");           // System.Windows.Forms.MessageBox.Show("重启程序绝对路径为" + filepath);
                p.StartInfo.FileName = filepath;
                p.Start();这么写就行了。应该是跨平台的原因。使用的是WINCE5.0系统。
      

  8.   

    楼主的主调用程序是不是也在WINCE上,如果在某台PC上的话,怎么执行WINCE设备上的程序真的不知道。
    如果和被调用的 重启.exe 在同一台WinCe设备上,那么应该是路径不对需要注意的是:在WinCe设备上不支持Application.StartupPath,
    要取得当前程序的路径,可以使用
    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
      

  9.   

    嗯,WINCE支持Application.StartupPath,确实要用Path.GetDirectoryName来获得路径
      

  10.   

    主调用程序也是在WINCE上,跟重启.exe在同一个路径下
      

  11.   

    说错,不支持Application.StartupPath