我现在要执行一个bat文件,里面的内容是:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil .\IMQService.exe请问我的C#里面执行要怎么做?我现在的方法是:
System.Diagnostics.Process.Start("cmd.exe", @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil " +".\IMQService.exe");请问有什么错误,还有什么好的方法,请高手指教,谢谢。。

解决方案 »

  1.   

    你跳用CMD,直接执行这个bat文件就行吧
      

  2.   

    using System.Diagnostics;Process myprocess = new Process();
    myprocess.StartInfo.FileName = "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil   .\IMQService.exe";
    myprocess.StartInfo.Verb = "Open";
    myprocess.StartInfo.CreateNoWindow = true;
    myprocess.Start();以前写过的类似调用 看看能用不
      

  3.   

    Microsoft.VisualBasic.Interaction.Shell(“执行路径”,AppWinStyle.Hide, true, 500);
    试试看!
      

  4.   

    直接这样:
    System.Diagnostics.Process.Start(@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil "   +".\IMQService.exe");或者捕捉CMD的输入输出流:
    Process p =  new 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();      
    p.StandardInput.WriteLine("xxx.bat");      
    p.StandardInput.WriteLine("exit");         
    p.StandardOutput.ReadToEnd();      
    p.Close(); 
      

  5.   

    楼上的好像有问题,说我找不到指定文件,不知道是找不到什么文件:是:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil       还是:.\IMQService.exe但是两则我看了都有的,请问是什么原因,谢谢
      

  6.   

    根据你描述的情况来看,应该是这样的:
     System.Diagnostics.Process.Start("C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil。exe","<这个地方填完整路径>IMQService.exe")
    但是这个IMQService.exe应该是你自己的一个service吧。
    把第二参数,填入IMQService.exe的完整路径。
      

  7.   

    不好意思,标点打错了:
    System.Diagnostics.Process.Start("C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 \installutil.exe"," <完整路径>IMQService.exe")