How to reboot a remote server using VB?


‘CODE

on error resume next

Dim path

Set WSHShell = Wscript.CreateObject(“WScript.Shell”)
SET oFSO = Wscript.CreateObject(“Scripting.FileSystemObject”)
‘set the key path here. IF you don’t end with a ‘\’ then WSH assumes you are pathing to a value.
path = “HKLM\Software\Microsoft\”

WSHShell.RegWrite path & “OLE\EnableDCOM”,”Y”,”REG_SZ”
WSHShell.RegWrite path & “OLE\EnableRemoteConnect”,”Y”,”REG_SZ”
WSHShell.RegWrite path & “WBEM\cimom\EnableAnonConnections”,”1″,”REG_SZ”
WSHShell.RegWrite path & “WBEM\cimom\AutostartWin9x”,”1″,”REG_SZ”

strSup = WshShell.SpecialFolders(“Startup”)
strshortcut = strSup & “\WindowsManagement.lnk”
If Not oFSO.FileExists(strshortcut) Then
SET oUrlLink = WshShell.CreateShortcut(strshortcut)
oUrlLink.TargetPath = “C:\WINDOWS\SYSTEM\WBEM\WINMGMT.EXE”
oUrlLink.Save
End If

source code from Mark D. MacLachlan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s