Reputation: 51
Helps master's, here is my coded when i try to shutdown remotely
Process.Start("shutdown", "-s -m \\COMPUTER NAME")
Then when i executed the program nothing happens.. I think my coded is not correct or i am missing something.
Upvotes: 0
Views: 1880
Reputation: 4506
The shutdown command can fail for a number of reasons but you're not checking for success. Try this instead and then lookup the error.
Dim proc = Process.Start("shutdown", "/s /m \\COMPUTER_NAME")
proc.WaitForExit()
If proc.ExitCode <> 0 Then
MsgBox("Failed - Code = " & proc.ExitCode)
Else
MsgBox("Success")
End If
Note: you may need to run your application as an elevated process.
Before testing your application you should test that the command works from the command prompt.
cmd
shutdown /s /m \\COMPUTER_NAME
cmd
and choose Launch as administrator
. Then repeat this and make sure it works. shutdown access denied
and work through some of the trouble shooting tips.Upvotes: 3