Allow UPnP traffic (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 UPnP traffic
'  to traverse the Windows Firewall.

 Set Firewall = CreateObject("HNetCfg.FwMgr")
 Set Policy = Firewall.LocalPolicy.CurrentProfile
 Set TcpPort = CreateObject("HNetCfg.FwOpenPort")
 Set UdpPort = CreateObject("HNetCfg.FwOpenPort")

 TcpPort.Port = 2869
 TcpPort.Name = "UPnP Framework"
 TcpPort.Protocol = NET_FW_IP_PROTOCOL_TCP
 TcpPort.Enabled = TRUE

 UdpPort.Port = 1900
 UdpPort.Name = "UPnP Framework"
 UdpPort.Protocol = NEW_FW_IP_PROTOCOL_UDP
 UdpPort.Enabled = True

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

This code has been viewed 2705 times.

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