ProcessStartInfo 错误(运行批处理文件)
我们继承了一些代码,它在 Windows Server 2003 机器和我的 Windows 7 64 位机器上运行良好。当我将其部署到 Windows Server 2008 R2 计算机时,代码无法运行,并且可能有权限执行某些操作。
代码是(在 ASP.NET Web 服务中):
public static void RunBatch(string file)
{
try
{
ProcessStartInfo startInfo;
Process batchExecute;
startInfo = new ProcessStartInfo(file);
startInfo.WorkingDirectory = @"C:\batch";
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
batchExecute = new Process();
batchExecute.StartInfo = startInfo;
batchExecute.Start();
batchExecute.StartInfo.CreateNoWindow = true;
batchExecute.WaitForExit();
batchExecute.Close();
}
catch (Exception ex)
{
Logger.WriteOutputLog("Exception in RunBatch: " + ex.Message.ToString());
}
}
当它被调用时,它只是“停止”,什么也没有发生,但也不会引发异常。
对于这段代码在没有某些配置的情况下不能在 Windows Server 2008 上运行有什么建议吗?
提前致谢。
更新: 它停止于
batchExecute.WaitForExit();
它启动一个 FTP 进程(似乎无法下载文件)
ftp -s:"C:\Batch\Commands.txt" ipNumber
ftp 进程尝试下载文件,在我的机器上它工作正常,但在服务器上它停止于 150 打开 fileName fileSize 的二进制模式数据连接
它可以连接到 FTP,而且我可以通过服务器上的浏览器浏览到它,没有任何问题。
we inherited some code and it is running fine on a windows server 2003 machine and on my windows 7 64bit machine. When I deploy it to a windows server 2008 R2 machine the code doesn't run and it might have something with permissions to do.
The code is (in an ASP.NET web service):
public static void RunBatch(string file)
{
try
{
ProcessStartInfo startInfo;
Process batchExecute;
startInfo = new ProcessStartInfo(file);
startInfo.WorkingDirectory = @"C:\batch";
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
batchExecute = new Process();
batchExecute.StartInfo = startInfo;
batchExecute.Start();
batchExecute.StartInfo.CreateNoWindow = true;
batchExecute.WaitForExit();
batchExecute.Close();
}
catch (Exception ex)
{
Logger.WriteOutputLog("Exception in RunBatch: " + ex.Message.ToString());
}
}
and when it gets invoked it just 'stops', nothing happens but no exception is raised.
Any suggestions on what might this piece of code to not run on a windows server 2008 without some configuration?
Thanks in advance.
Update:
it stops at
batchExecute.WaitForExit();
It starts an FTP process (that doesn't seem to be able to download files)
ftp -s:"C:\Batch\Commands.txt" ipNumber
the ftp process tries to download a file and on my machine it works fine but on the server it stops at
150 Opening Binary mode data connection for fileName fileSize
It can connect to the FTP though and I can browser to it through the browser on the server without issues.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论