system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法

有时候我们需要在程序中调用 cmd.exe  执行一些命令  

比如 我们会在程序写到

  /// <summary>
        /// 执行Cmd命令
        /// </summary>
        /// <param name="workingDirectory">要启动的进程的目录</param>
        /// <param name="command">要执行的命令</param>
        private void StartCmd(String workingDirectory, String command)
        {
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.WorkingDirectory = workingDirectory;
            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(command);
            //p.StandardInput.WriteLine("exit");
        }

代码是一点问题都没有的。你在本地调试也没有问题。

可是就是一放到服务器上。就可能出现  system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法

在服务器中将你代码中要调用的的

workingDirectory 目录  的internet来宾账户设置为完全控制即可。
Top
收藏
关注
评论
原文地址:https://www.cnblogs.com/alanjl/p/3830659.html