
'Script to Configure Reply Ports For WMI
'=======================================
' Product: ManageEngine ServiceDeskPlus (or) ManageEngine AssetExplorer


'WARNING:
'********
'	This script edits Windows Registry to configure the Settings needed for Scanning
'	It is highly recomended to test the script in a Test Computer before rolling it across a Network


'NOTE:
'*****
' This segment defines the range of ports that will be set in the Registry.
' To Customize the range, configure the same below. However it is recomended to have minimum of 3 ports in the range.

startPort = 5000
endPort = 5002


'Other definitions used in the script.
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
strKeyPath = "SOFTWARE\Microsoft\Rpc\Internet"
strValueName1 = "Ports"
strValue = startPort & "-" & endPort
arrStringValues = Array(strValue)
strValueName2 = "PortsInternetAvailable"
strValueName3 = "UseInternetPorts"


'Connection to Local Registry
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")


'Creates the Registry Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath


'Writes the Values in Registry ==> Ports: 5000-5002  
oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,arrStringValues


'Writes the Values in Registry ==> PortsInternetAvailable: Y
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName2,"Y"


'Writes the Values in Registry ==> UseInternetPorts: Y
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName3,"Y"


