我想在使用PSEXEC工具的远程计算机上运行命令,它使用命令提示符成功运行,但它在显示以下内容的asp.net项目中失败输出错误。PSEXEC通过命令提示符成功运行,但在ASP.Net/C中失败#
PSEXEC V2.11 - 执行过程远程版权(C)2001至2014年马克 Russinovich介绍的Sysinternals - www.sysinternals.com
句柄无效。
连接到lnxdevx ...
开始对lnxdevx PSEXESVC服务...
与lnxdevx PSEXEC服务连接...
错误派生会话密钥:。
这是我的示例c#代码。
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.FileName = @"C:\Windows\System32\PsExec.exe";
p.StartInfo.Arguments = "-u xxxxxx -p xxxxxxxxxx \\\\lnxdevx -i -d -w \"C:\\DIRECTORY\" cmd.exe /C dir";
p.Start();
string output = p.StandardOutput.ReadToEnd();
string errormessage = p.StandardError.ReadToEnd();
p.WaitForExit();
你有没有尝试将UseShellExecute更改为true? (这似乎是默认) –