|
MeenEnta -> RE: SP3 firewall issue (10/28/2008 12:53:29 PM)
|
And as promissed, here's the code we used to push via GPO. 'This script disables the firewall under each profile const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SYSTEM\CurrentControlSet\Control\IDConfigDB\Hardware Profiles" strProfileKeyP1 = "SYSTEM\CurrentControlSet\Hardware Profiles\" strProfileKeyP2 = "\System\CurrentControlSet\Enum\ROOT\LEGACY_SHAREDACCESS\0000" strRootPath = "\System\CurrentControlSet\Enum\ROOT\LEGACY_SHAREDACCESS" strSystemPath = "\System" strValueFriendlyName = "FriendlyName" strValueFlagName = "CSConfigFlags" 'Enumerate profile names oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys 'Find the profile name in the registry For Each subkey In arrSubKeys 'Get the "friendly Name" of the profile oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey,strValueFriendlyName,strValueName 'If the name exists, check the flag associated with the FW If Len(strValueName) > 0 Then 'wscript.echo strProfileKeyP1 & subkey & strRootPath oReg.EnumKey HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strSystemPath, arrSystemSubKeys oReg.EnumKey HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strRootPath, arrRootSubKeys bolFoundLegacyKey = false bolFoundSysSubKey = false 'wscript.echo err.number & " " & err.Description & " isArray " & IsArray(arrRootSubKeys) If IsArray(arrRootSubKeys) Then For Each subRootKey In arrRootSubKeys If subRootKey = "0000" Then bolFoundLegacyKey = true End If Next End If If IsArray(arrSystemSubKeys) Then bolFoundSysSubKey = true End If If bolFoundSysSubKey Then If bolFoundLegacyKey Then oReg.GetDWORDValue HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strProfileKeyP2,strValueFlagName,strValueFlag 'If the flag exists, check if already disabled, if not set to disabled if NOT isNull(strValueFlag) Then If strValueFlag = 0 Then Wscript.Echo strValueName & ": FW already enabled." Else Wscript.Echo strValueName & ": Enabling FW for " & strValueName oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strProfileKeyP2,strValueFlagName,0 End If End If Else Return = oReg.CreateKey(HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strProfileKeyP2) If (Return = 0) And (Err.Number = 0) Then Wscript.Echo strValueName & ": Created subkey and setting value." oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strProfileKeyP1 & subkey & strProfileKeyP2,strValueFlagName,0 Else Wscript.Echo "CreateKey failed. Error = " & Err.Number End If End If Else Wscript.Echo strValueName & ": Does not contain a FW entry, bypassing." End If End If 'Wscript.Echo "Profile: " & subkey & " friendly name is [" & strValueName & "] >> Flag: " & strValueFlag Next Wscript.Echo "Done."
|
|
|
|