27 April 2013

Script to add a web site to IE's Trusted Sites

UPDATE: Instead of a script, a neater way would be to add the relevant registry keys using Group Policy Preferences. But the script method below may still be useful in some situations.

Why use a script? Because doing it via the fucking GPO setting overwrites what the user had and also prevents them from adding their own. Enjoy.

Option Explicit
Dim oShell
Set oShell = WScript.CreateObject("WScript.Shell")
' http://support.microsoft.com/kb/182569
Dim sSite, sDValue, sZone, sKey, sZonesPath, aKeys, aKey
sZonesPath="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains"
' create key
aKeys = array( _
array(sZonesPath & "\the.website.to.trust.com\","","1") _
For Each aKey in aKeys
' create key for sSite
oShell.RegWrite akey(sSite), akey(sDvalue)
' add * dword under the site's key and set the szone
sKey=akey(sSite) & "*"
oShell.RegWrite sKey, akey(sZone), "REG_DWORD"

Shout-out to Zoredache.

No comments:

Post a Comment