Кто-нибудь знает, в чем может быть проблема?
Код: Выделить всё
private void ShutdownRemotePC(string ipAddress)
{
try
{
string command = $"psexec \\\\{ipAddress} -s shutdown /s /t 0";
ProcessStartInfo processInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/C {command}",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process process = Process.Start(processInfo))
{
process.WaitForExit();
if (process.ExitCode == 0)
{
MessageBox.Show("원격 컴퓨터 종료 명령 전송 완료.");
}
else
{
MessageBox.Show("원격 종료 명령 실패. 권한 문제가 있을 수 있습니다.");
}
}
}
catch (Exception ex)
{
MessageBox.Show("원격 종료 오류: " + ex.Message);
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... nforms-app
Мобильная версия