Remote Reboot in VB.NET

  • Thread starter Thread starter ---------- Eric ----------
  • Start date Start date
E

---------- Eric ----------

How would i go about rebooting a remote computer from code
running on this local computer?

Bacsically i have a service running on machine A, it
checks the status of a service on machine B. If the
service on machine B fails, the service on machine A needs
to tell machine B to reboot.

Thanks
Eric.
 
Why not use the service control classes and just restart
the services. Then you would reduce the risk of the
machine not coming back up.

Glenn
 
I think the Management (WMI) Extensions for VS.NET PDC version Server
Explorer is helpful for this problem. You may install Management (WMI)
Extensions for VS.NET PDC version Server Explorer from the link below:

http://go.microsoft.com/fwlink/?LinkId=3353

And then take the following steps to generate the code for rebooting a
remote machine.

1. Create a Windows Application project in Visual C#
2. Click the Server Explorer and browser to:

Servers\<your local machine>\Management Classes\Operating Systems\<your
current system>

3. Drag the system to your form
4. Modify the Win32_OperatingSystem.CS file generated by IDE and let it
connect to the target machine
5. Add the following code to your program:

operatingSystem1.Reboot();

6. Build and run the application

You may refer to the link below to get more detailed information about how
to use WMI in VS.NET:

http://msdn.microsoft.com/library/en-us/wmise/wmioriManagingWindowsManagemen
tInstrumentationWMIDataEventsWithServerExplorer.asp

I hope this helps you.

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top