Option Explicit ' Adds airparrot.exe to Windows Firewall ' Deletes first old entries ' mikko@utu.fi 2014-10-28 Dim objShell Dim strCmdLineDeleteRule Dim strCmdLineAddTCPRule Dim strCmdLineAddUDPRule Dim intReturnCode Dim objProcEnv Dim strProgramFilesPath Set objShell = CreateObject("Wscript.Shell") Set objProcEnv = objShell.Environment("PROCESS") strProgramFilesPath = objProcEnv("SystemDrive")+"\Program Files" intReturnCode = 0 ' Prepare netsh command lines (show, delete, add TCP, add UDP) strCmdLineDeleteRule = "netsh AdvFirewall Firewall delete rule name=""AirPlay Mirroring Client""" strCmdLineAddTCPRule = "netsh AdvFirewall Firewall add rule name=""AirPlay Mirroring Client"" dir=in action=allow program=""" & strProgramFilesPath & "\airparrot\airparrot.exe"" profile=any protocol=TCP edge=deferuser" strCmdLineAddUDPRule = "netsh AdvFirewall Firewall add rule name=""AirPlay Mirroring Client"" dir=in action=allow program=""" & strProgramFilesPath & "\airparrot\airparrot.exe"" profile=any protocol=UDP edge=deferuser" ' Delete existing AirParrot firewall rules Do intReturnCode = objShell.Run(strCmdLineDeleteRule, 0, True) ' returns: 0 if deleted successfully, 1 if nothing to delete Loop Until intReturnCode = 1 ' Repeat until all old rules are deleted ' Add new firewall rules for airparrot.exe ' TCP rule intReturnCode = objShell.Run(strCmdLineAddTCPRule, 0, True) If Not intReturnCode = 0 Then wScript.Quit(intReturnCode) End If ' UDP rule intReturnCode = objShell.Run(strCmdLineAddUDPRule, 0, True) WScript.Quit(intReturnCode)