我在c#中调用cmd.exe执行ping命令正常,但是我执行set 命令和ren 命令都不能正常执行。
是不是权限的问题?但是我把要批量改名的文件夹赋予了asp.net和everyone的写权限还是不能执行ren的批量修改和set系统变量!!!
请高手指点。
是不是权限的问题?但是我把要批量改名的文件夹赋予了asp.net和everyone的写权限还是不能执行ren的批量修改和set系统变量!!!
请高手指点。
private static string runcmd(string command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
return p.StandardOutput.ReadToEnd();
}调用runcmd(@"ren C:\1.txt 1.xml");
ping直接就是一个ping.exe
在ren前加上cmd.exe /c
就可以了
这个应该是正解,ren是内部命令,ping是外部命令,楼主可以试试xcopy能不能执行,再试试dir命令,如果xcopy能执行而dir不行那就是这个问题了。