' From: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/wf_adding_an_application.asp Option Explicit if WScript.arguments.length = 0 then WScript.echo "Please supply the name of the executable to be added to the" WScript.echo "Windows Firewall exception list. It must be in the" WScript.echo "current directory." WScript.echo "Example usage: FirewallExceptionAdd.vbs TrafficCam_Viewer_service.exe" WScript.quit end if ' Set constants Const NET_FW_PROFILE_DOMAIN = 0 Const NET_FW_PROFILE_STANDARD = 1 ' Scope ' Use NET_FW_SCOPE_ALL if you want to open it up globally, BELOW ALSO 'Const NET_FW_SCOPE_ALL = 0 Const NET_FW_SCOPE_LOCAL_SUBNET = 1 ' IP Version – ANY is the only allowable setting for now Const NET_FW_IP_VERSION_ANY = 2 ' Declare variables Dim errornum ' Create the firewall manager object. Dim fwMgr Set fwMgr = CreateObject("HNetCfg.FwMgr") ' Get the current profile for the local firewall policy. Dim profile Set profile = fwMgr.LocalPolicy.CurrentProfile Dim app Set app = CreateObject("HNetCfg.FwAuthorizedApplication") ' Build the path to the executable Dim WshShell Dim FullPathToService Set WshShell = WScript.CreateObject("WScript.Shell") FullPathToService = WshShell.CurrentDirectory + "\" + Wscript.arguments.item(0) 'WScript.Echo FullPathToService app.ProcessImageFileName = FullPathToService app.Name = "TiVo: TrafficCam Viewer Service" app.Scope = NET_FW_SCOPE_LOCAL_SUBNET ' Use either Scope or RemoteAddresses, but not both 'app.RemoteAddresses = "*" app.IpVersion = NET_FW_IP_VERSION_ANY app.Enabled = TRUE ' Use this line if you want to add the app, but disabled. 'app.Enabled = FALSE On Error Resume Next errornum = 0 profile.AuthorizedApplications.Add app errornum = Err.Number if errornum <> 0 then Wscript.Echo("Adding authorized application failed with: " & errornum)