I’m trying to shutdown a windows computer in my network, from a windows service running on another windows computer.
In the console, I can do that:
net use \\ComputerName Password /u:User
shutdown /s /t 0 /m \\ComputerName
But when I try to do it from my windows service:
Process.Start("net", "use \\ComputerName Password /u:User");
Process.Start("shutdown", "/s /t 0 /m \\ComputerName");
Nothing happens.
I know there is a permissions problem because my service is running on LocalSystem account, but I tried to change it to my local user and still not working.
Any help will be appreciated.
For what it is worth, you can do this progmatically using the documented WMI Win32_OperatingSystem/Win32Shutdown method.
The linked article also as has links to examples on how to use WMI from C++