当前位置: 代码迷 >> ASP.NET >> 在执行完winexec()之后,怎样再执行后续程序的有关问题
  详细解决方案

在执行完winexec()之后,怎样再执行后续程序的有关问题

热度:8535   发布时间:2013-02-25 00:00:00.0
在执行完winexec()之后,怎样再执行后续程序的问题
我的部分程序是这样的:
C# code
if (File.Exists(path_pre + "beijing.opx"))        {            WinExec(@"E:\noise\noisemap\Noisemap\NMap\Run Beijing NMap Case.bat", 5);        }        else        {            Response.Write("<script>alert('.opx文件不存在!');</script>");        }        ChangeName();

在执行完WinExec()(这里是运行一个软件)之后,后面的ChangeName()函数就没执行,怎样解决这个问题?

------解决方案--------------------------------------------------------
try 

Process pro=new Process(); 
pro.StartInfo.UseShellExecute=true; 
pro.StartInfo.FileName=@ "c:\1.bat "; 
pro.StartInfo.CreateNoWindow=true; 
pro.Start(); 

catch(Exception ex) 
{MessageBox.Show(ex.Message);}
------解决方案--------------------------------------------------------
探讨

try
{
Process pro=new Process();
pro.StartInfo.UseShellExecute=true;
pro.StartInfo.FileName=@ "c:\1.bat ";
pro.StartInfo.CreateNoWindow=true;
pro.Start();
}
catch(Exception ex) ……

------解决方案--------------------------------------------------------
pro.Start(); 后面应该加上一句

pro.WaitForExit();