Configure port exception (VBScript)

This code can be found in Chapter 3 of Windows Server 2003 Networking Recipes

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Windows Server 2003 Networking Recipes"

' This code allows an application named FOO using TCP port 11065
'  to traverse the Windows Firewall.
' ------ SCRIPT CONFIGURATION ------
 Set Firewall = CreateObject("HNetCfg.FwMgr")
 Set Policy = Firewall.LocalPolicy.CurrentProfile
 Set Port = CreateObject("HNetCfg.FwOpenPort")
' ------ END CONFIGURATION ---------

 Port.Port = 11065
 Port.Name = "FOO"
 Port.Protocol = NET_FW_IP_PROTOCOL_TCP
 Port.Enabled = TRUE

 set Ports = Policy.GloballyOpenPorts
 addedPorts = Ports.Add(Port)
WScript.Echo "Ports configured."

This code has been viewed 1928 times.

New from the creators of TechTasks.com: StatSheet.com