Link to home
Create AccountLog in
Avatar of noppen
noppen

asked on

Need Code to shut down a remote machine

I need a code example for rebooting a remote server on a WAN network from within an asp.net 1.1 web app. I'm using vb.net in VS 2003
Whatever permissions and references are needed should be specified also.  Command options (e.g. poweroff, etc) would also be usedful
Thanks in advance

Avatar of QBRad
QBRad
Flag of United States of America image

There are DOS commands that can shutdown a remote computer as well as restart it.  If you go into a DOS prompt and type shutdown and press enter it will list all the syntax as well as options/switches that you can use with this command.
Avatar of noppen
noppen

ASKER

QBRad:

pls read the question again:  "from WITHIN an app" not from a dos console!
something equivalent the code below but for a machine reboot instead of a service reboot
Sub ReStartW3SvcData1(ByVal s As [Object], ByVal e As EventArgs) Handles btnReStartW3SvcData1.Click
Dim _Controller As New ServiceController("w3svc", "Data1")
If _Controller.CanStop Then _Controller.Stop()
_Controller.Start()
End Sub '

Open in new window

System.Diagnostics.Process.Start("shutdown", "-r -f -t 1")
Avatar of noppen

ASKER

When run (see code below), the above command raises " file not found" error.....

Sub RestartDev1(ByVal s As [Object], ByVal e As EventArgs) Handles btnRestartDev1.Click  
 
System.Diagnostics.Process.Start("shutdown", "-r -f -t 1")
 
End Sub 

Open in new window

Try...

System.Diagnostics.Process.Start("C:\Windows\System32\shutdown.exe", "-r -f -t 1")
Avatar of noppen

ASKER

The machine just shuts down, i.e. does'nt reboot. That defeats the whole purpose

I tried w/ psshutdown instead:
System.Diagnostics.Process.Start("d:\foldername\psshutdown.exe", "\\machinename -r")

No error, but no shutdown either...

I believe the arguments above are correct

What gives?
ASKER CERTIFIED SOLUTION
Avatar of noppen
noppen

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account