#136271 - 2005-03-24 09:31 AM
ModifyXPFirewall() - Set or Read some XP Firewall settings
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11629
Loc: CA
Well based on the UDF posted here, I was unable to confirm the keys being used there and wrote this one.XPFirewall() - Turns on|off the Windows XP Service Pack 2 firewall Note: Only tested with KiXtart v4.22 on English XP w/SP2 installed and local admin rights 1. User must have Admin Rights to run 2. If Firewall is currently set and functioning, and does not already allow open ports to allow KiXtart to set, it will not work 3. Typically script / UDF would be used to prepare the settings BEFORE rolling out SP2 for systems that do not have GPO access or systems that are in Workgroups. Please test, provide feedback before I post in the UDF forum. IPv6 Internet Connection Firewall NOT SUPPORTED ICF DomainProfile Defines changes to Windows Firewall’s default configuration when a computer is connected to a network that contains domain controllers for the domain of which the computer is a member. ICF StandardProfile Defines changes to Windows Firewall’s default configuration when a computer is not connected to a network that contains domain controllers for the domain of which the computer is a member. If a computer is not a member of a domain, Windows Firewall uses the configuration stored in the standard profile.Dim $XPFire ;This first run SETS the firewall settings for BOTH profiles $XPFire = ModifyXPFirewall ('Enigma' ,'B' ,1 ,0 ,1 ,1 );This second run READS the firewall settings and ignores other values when write not set $XPFire = ModifyXPFirewall ('Enigma' ,'B' ,0 ,1 ,1 ,0 ) ? 'Domain Profile DisableNotifications: ' + $XPFire [0 ] ? 'Domain Profile DoNotAllowExceptions: ' + $XPFire [1 ] ? 'Domain Profile EnableFirewall: ' + $XPFire [2 ] ? 'Standard Profile DisableNotifications: ' + $XPFire [3 ] ? 'Standard Profile DoNotAllowExceptions: ' + $XPFire [4 ] ? 'Standard Profile EnableFirewall: ' + $XPFire [5 ]Function ModifyXPFirewall($sComputer ,$Profile ,$Action ,$Noti ,$Allow ,$Fire ) Dim $DProfile , $SProfile , $DNoti , $DAllow , $DFire , $SNoti , $SAllow , $SFire , $EpochKey , $Read , $Set $DNoti ="" $DAllow ="" $DFire ="" $SNoti ="" $SAllow ="" $SFire ="" If $sComputer $sComputer = '\\' + Join (Split ($sComputer ,'\' ),'' ,3 ) + '\' EndIf $EpochKey = $sComputer + 'HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Epoch' $DProfile = $sComputer + 'HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile' $SProfile = $sComputer + 'HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile' $Read = ReadValue ($EpochKey ,'Epoch' ) If $Action = 1 Select Case $Profile = 'D' ; Writes supplied value to Domain profile $Set = WriteValue ($DProfile ,'DisableNotifications' ,$Noti ,REG_DWORD ) $Set = WriteValue ($DProfile ,'DoNotAllowExceptions' ,$Allow ,REG_DWORD ) $Set = WriteValue ($DProfile ,'EnableFirewall' ,$Fire ,REG_DWORD ) $Set = WriteValue ($EpochKey ,'Epoch' ,($Read +1 ),REG_DWORD ) Case $Profile = 'S' ; Writes supplied value to Standard profile $Set = WriteValue ($SProfile ,'DisableNotifications' ,$Noti ,REG_DWORD ) $Set = WriteValue ($SProfile ,'DoNotAllowExceptions' ,$Allow ,REG_DWORD ) $Set = WriteValue ($SProfile ,'EnableFirewall' ,$Fire ,REG_DWORD ) $Set = WriteValue ($EpochKey ,'Epoch' ,($Read +1 ),REG_DWORD ) Case $Profile = 'B' ; Writes supplied value to both profiles $Set = WriteValue ($DProfile ,'DisableNotifications' ,$Noti ,REG_DWORD ) $Set = WriteValue ($DProfile ,'DoNotAllowExceptions' ,$Allow ,REG_DWORD ) $Set = WriteValue ($DProfile ,'EnableFirewall' ,$Fire ,REG_DWORD ) $Set = WriteValue ($SProfile ,'DisableNotifications' ,$Noti ,REG_DWORD ) $Set = WriteValue ($SProfile ,'DoNotAllowExceptions' ,$Allow ,REG_DWORD ) $Set = WriteValue ($SProfile ,'EnableFirewall' ,$Fire ,REG_DWORD ) $Set = WriteValue ($EpochKey ,'Epoch' ,($Read +1 ),REG_DWORD ) Case 1 Exit 1 EndSelect Else $DNoti = ReadValue ($DProfile ,'DisableNotifications' ) $DAllow = ReadValue ($DProfile ,'DoNotAllowExceptions' ) $DFire = ReadValue ($DProfile ,'EnableFirewall' ) $SNoti = ReadValue ($SProfile ,'DisableNotifications' ) $SAllow = ReadValue ($SProfile ,'DoNotAllowExceptions' ) $SFire = ReadValue ($SProfile ,'EnableFirewall' ) EndIf $ModifyXPFirewall =$DNoti , $DAllow , $DFire , $SNoti , $SAllow , $SFire EndFunction
Top
Moderator: Glenn Barnas , NTDOC , Arend_ , Jochen , Radimus , Allen , ShaneEP , Ruud van Velsen , Mart
0 registered
and 2235 anonymous users online.