MrP*_*ram 3 c# psexec remote-server
我正在尝试在远程计算机上执行notepad.exe,但它现在不能正常工作.我错过了什么?
var ui = new ImpersonateUser();
//the process to restart
const string processName = "notepad.exe";
var serverName = "serverName";
try
{
//Use adbadmin for access
ui.Impersonate(_domain, _userName, _pass);
//Start the process
ProcessStartInfo info = new ProcessStartInfo("C:\\PsTools");
info.FileName = @"C:\PsTools\psexec.exe";
info.Arguments = @"""\\" + serverName + @"C:\WINDOWS\notepad.exe""";
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
lblStatusResponse.Text = "Service " + processName + " was restarted correctly.";
}
catch (Exception ex)
{
lblStatusResponse.Text = ex.ToString();
}
finally
{
ui.Undo();
}
Run Code Online (Sandbox Code Playgroud)
这让我也不例外,但我肯定错过了一些东西......
答案是你的回复的组合.但是整个正确的解决方案是:
ProcessStartInfo info = new ProcessStartInfo("C:\\PsTools");
info.FileName = @"C:\PsTools\psexec.exe";
info.Arguments = @"\\" + serverName + @" -i C:\WINDOWS\notepad.exe";
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22897 次 |
| 最近记录: |