ProcessStartInfo出错(运行批处理文件)

时间:2011-05-27 03:45:15

标签: c# windows-server-2008

我们继承了一些代码,它在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,我可以通过服务器上的浏览器浏览到它而没有问题。

0 个答案:

没有答案