2012-01-31 79 views
1

我的问题是多层次的。我想编写一个windows服务来执行带有自定义参数的SoapUI testrunner.bat批处理文件。启动并调试执行SoapUI的服务testrunner.bat批处理文件

该服务安装正常,但无法启动,除非它是在发布模式下构建的。如果我以调试模式构建它,请安装并尝试启动它,但无法启动。

我无法调试,因为“附加到进程”按钮是灰色的。

现在,最大的问题是,当服务启动时,它似乎没有做任何事情。没有生成日志文件。

这里是我的代码:

System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
proc.StartInfo.FileName = "D:\\testrunner.bat"; 
proc.StartInfo.Arguments = "-sServiceTest1 -cLoadBalancingTest -r -fd:\\temp -R\"TestCase Report\" -FPDF D:\\TestProj.xml"; 
proc.StartInfo.UseShellExecute = true; 

proc.Start(); 

我在做什么错?

P.S.我正在运行Windows 7.

回答

1

要回答我自己的问题,没有任何工作原因之一是因为我错误地配置了服务安装程序。

using (System.Diagnostics.Process proc = new System.Diagnostics.Process()) 
{ 
    proc.StartInfo.FileName = "testrunner.bat"; 
    proc.StartInfo.Arguments = "blah blah blah"; 
    proc.StartInfo.RedirectStandardError = true; 
    proc.StartInfo.RedirectStandardOutput = true; 
    proc.StartInfo.UseShellExecute = false; 
    proc.Start(); 
    outputMessage = proc.StandardOutput.ReadToEnd(); 

    logFile = File.AppendText("D:\\temp\\SoapUITest.log"); 
    logFile.AutoFlush = true; 
    logFile.Write(outputMessage); 
    logFile.Close(); 
} 

上面的代码工作正常,虽然我没有用手installutil

+0

安装这不是批处理脚本。这是PowerShell吗? – djangofan 2013-04-29 17:57:10