有时候我们需要在程序中调用 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来宾账户设置为完全控制即可。

system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法的更多相关文章

  1. System.ComponentModel.Win32Exception (0x80004005): 无效的窗口句柄。

    原文:System.ComponentModel.Win32Exception (0x80004005): 无效的窗口句柄. 在 WPF 获取鼠标当前坐标的时候,可能会得到一个异常:System.Co ...

  2. System.ComponentModel.Win32Exception (0x80004005):拒绝访问。——解决办法

    一.问题如下: (无法执行程序.所执行的命令为 "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /noconfi ...

  3. 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问。

    本地win7 本地正常,服务器win2008r2,服务器报错! 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问. 拒绝访问. 说明: 执行当前 W ...

  4. win10更新后出现System.ComponentModel.Win32Exception

    win10更新后出现System.ComponentModel.Win32Exception 我的环境是由于“sql server2012 无法连接到WMI提供程序”引起的 参考http://www. ...

  5. IOS开发证书变成“此证书的签发者无效”解决方法

    IOS开发证书全部变成无效,如下图  打包提示错误  解决方法: 1. 下载https://developer.apple.com/certificationauthority/AppleWWDRCA ...

  6. windows服务安装(System.ComponentModel.Win32Exception:远程过程调用失败)

    “安装”阶段发生异常.System.ComponentModel.Win32Exception:远程过程调用失败 附上提示信息C:\Windows\Microsoft.NET\Framework\v4 ...

  7. (转)调用System.gc没有立即执行的解决方法

    调用System.gc没有立即执行的解决方法 查看源码 当我们调用System.gc()的时候,其实并不会马上进行垃圾回收,甚至不一定会执行垃圾回收,查看系统源码可以看到 /** * Indicate ...

  8. Oracle system表空间满的暂定解决方法

    Oracle system表空间满的暂定解决方法 数据库用的是Oracle Express 10.2版本的.利用Oracle Text做全文检索应用,创建用户yxl时没有初始化默认表空间,在系统开发过 ...

  9. 2 字节的 UTF-8 序列的字节 2 无效 解决方法

    2 字节的 UTF-8 序列的字节 2 无效 解决方法: 用记事本打开xml文件,另存为 编码 选择 UTF-8,保存替换掉之前的文件,解决问题

随机推荐

  1. caffe源码整个训练过程

    Caffe源码 Blob protected: shared_ptr<SyncedMemory> data_; shared_ptr<SyncedMemory> diff_; ...

  2. POJ2528 Mayor's posters(线段树染色问题+离散化)

    题目大意:有t组数据,每组数据给你n张海报(1<=n<=10000),下面n组数据分别给出每张海报的左右范围(1 <= l <= r <= 10000000),下一张海报 ...

  3. 20165301实验二java面向对象程序设计

    20165301实验二java面向对象程序设计 实验目的与要求(提交点一): 参考http://www.cnblogs.com/rocedu/p/6371315.html#SECUNITTEST完成单 ...

  4. [MySQL]You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

    执行update语句,出现问题: 问题描述: You are using safe update mode and you tried to update a table without a WHER ...

  5. hdu 5912(迭代+gcd)

    Fraction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  6. 洛谷 P2369 EXCEEDED WARNING A 题解

    题目传送门 直接用sort排序最后输出即可.但是数组要使用short int 类型.否则会超内存. #include<bits/stdc++.h> using namespace std; ...

  7. Characters_of_the_Three_Kingdoms - 三国人物结构化数据

    Characters_of_the_Three_Kingdoms - 三国人物结构化数据 三国人物结构化数据 为什么会有这个项目 需求1:摆脱网上那些长篇累牍的文章: 需求2:只是想简单查看下人物姓甚 ...

  8. 八大排序算法JS及PHP代码实现

    从学习数据结构开始就接触各种算法基础,但是自从应付完考试之后就再也没有练习过,当在开发的时候也是什么时候使用什么时候去查一下,现在在学习JavaScript,趁这个时间再把各种基础算法整理一遍,分别以 ...

  9. 几个python one-liner

    生成斐波那契数列的前10个数,从1开始.若生成前n个,改为range(n-2).代码很简单: List = reduce(lambda x, y: x + [x[-1] + x[-2]], range ...

  10. Loadrunner中cookie解释与用法

    loadrunner对于cookie的处理loadrunner中与cookie处理相关的常用函数如下: web_add_cookie():添加新的cookie或者修改已经存在的cookie web_r ...