长话短说...
这不起作用:
Process p = new Process();
p.StartInfo.FileName = @"External\PsExec.exe";
string file = String.Concat(Path.Combine(Environment.CurrentDirectory,"temp"),@"\iisreset",DateTime.Now.ToString("ddMMyyyy-hhmmssss"),".txt");
p.StartInfo.Arguments = String.Format("-s -u {0}\\{1} -p {2} \\\\{3} iisreset > \"{4}\"", Domain,UserName, Password, machineIP, file);
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
我收到 RPC 不可用消息。
但是当我访问程序文件夹中的命令行时,我运行这个:(使用正确的参数),就像我在文件名/参数中指定的那样......
External\PsExec.exe -s -u [user] -p [password] \\[ip] iisreset > "[path]"
有用!我是否必须在 C# Process 中指定其他任何内容?可能会发生什么?
提前致谢!
编辑:如果我把文件名放在参数之前,它cmd
会起作用/c PsExec.exe
。问题是这样它总是显示窗口。