WMI Filtering on XP machines query
#1
Scooby Regular
Thread Starter
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes
on
0 Posts
WMI Filtering on XP machines query
Hi All,
I need to make a WMI filter that checks for a registry key value and only applies to Windows XP machines.
----------------------------------------------------------------------
HKEY_LOCAL_MACHINE\Software\KasperskyLab\AVP6\Sett ings
Key called EnableSelfProtection
1 = Self defence on
0 = Self defence off
----------------------------------------------------------------------
I need it to apply only if the above value is zero
I already have the filter for XP machines only but can I have 2 conditions in a WMI filter?
I cannot use item level targeting as it's for a software install
Has anyone done something similar. I think VB scripts are an option but I'm turd at them
I need to make a WMI filter that checks for a registry key value and only applies to Windows XP machines.
----------------------------------------------------------------------
HKEY_LOCAL_MACHINE\Software\KasperskyLab\AVP6\Sett ings
Key called EnableSelfProtection
1 = Self defence on
0 = Self defence off
----------------------------------------------------------------------
I need it to apply only if the above value is zero
I already have the filter for XP machines only but can I have 2 conditions in a WMI filter?
I cannot use item level targeting as it's for a software install
Has anyone done something similar. I think VB scripts are an option but I'm turd at them
#2
Are you talking about doing something like this in VBScript?
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
If objOperatingSystem.Caption = "Microsoft Windows XP" Then
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" & strComputer & "\root\default:StdRegProv")
strKeyString = "EnableSelfProtection"
strKeyPath = "Software\KasperskyLab\AVP6\Settings"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strKeyString, strValue
If IsNull(strValue) Then
WScript.Echo "Reg Key doesn't exist!"
WScript.quit
elseIf strValue = "0" Then
WScript.Echo "Do whatever you need to do"
WScript.Quit
Else
WScript.Echo "Value data not 0!"
Wscript.Quit
End If
End If
Next
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
If objOperatingSystem.Caption = "Microsoft Windows XP" Then
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" & strComputer & "\root\default:StdRegProv")
strKeyString = "EnableSelfProtection"
strKeyPath = "Software\KasperskyLab\AVP6\Settings"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strKeyString, strValue
If IsNull(strValue) Then
WScript.Echo "Reg Key doesn't exist!"
WScript.quit
elseIf strValue = "0" Then
WScript.Echo "Do whatever you need to do"
WScript.Quit
Else
WScript.Echo "Value data not 0!"
Wscript.Quit
End If
End If
Next
Thread
Thread Starter
Forum
Replies
Last Post