Add IP Address to Zone

This will allow you to scriptomatically add an IP Address to an Internet Security Zone

on error resume next

Set objShell = CreateObject(“Wscript.Shell”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Const HKEY_LOCAL_MACHINE = &H80000002
Const OverwriteExisting = TRUE

‘SETS CURRENT DIRECTORY TO VARIABLE
strCurrentDirectory = objShell.CurrentDirectory

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set objRegistry=GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)
strKeyPath = “SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
on error resume next
strValueName = “ProfileImagePath”
strSubPath = strKeyPath & “\” & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
Const POPUP_TITLE = “User To SID Conversion”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set objAccount = objWMIService.Get(“Win32_SID.SID='” & objSubkey & “‘”)
strUser = objAccount.AccountName
‘strDomain = objAccount.ReferencedDomainName’returns referenced domain

‘DISPLAY PROFILE NAME & SID
objSubkey = trim(objSubkey)’trims whitespace
strUser = trim(strUser)’trims whitespace
‘msgbox “objSubkey: ” & objSubkey’returns SID
‘msgbox strUser’returns username

‘LOGIC TO DETERMINE IF REGISTRY ACCOUNT IS TO BE LOADED
if strUser = “SYSTEM” then strUser=””
if strUser = “LOCAL SERVICE” then strUser=””
if strUser = “NETWORK SERVICE” then strUser=””
if strUser = “ADMINISTRATOR” then strUser=””

if strUser <> “” then
on error resume next
‘ADD TO ZONE
objShell.Run “%comspec% /c reg.exe add “&chr(34)&”HKEY_USERS\” & objSubkey & “\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1″&chr(34),0,true
objShell.Run “%comspec% /c reg.exe add “&chr(34)&”HKEY_USERS\” & objSubkey & “\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1″&chr(34)&” /t REG_DWORD /v * /d 00000002 /f”,0,true
objShell.Run “%comspec% /c reg.exe add “&chr(34)&”HKEY_USERS\” & objSubkey & “\Software\Microsoft\Windows\CurrentVersion\Internet Settings”&chr(34)&” /t REG_SZ /v :Range /d 127.0.0.1 /f”,0,true
end if

Next

email me