You can create a WMI filter for your GPO that filter ONLY your XP clients.
The query used for that is : [code:1]SELECT * FROM Win32_OperatingSystem WHERE Caption = 'Microsoft Windows XP Professionnel'[/code]
I have an environment that has both Windows 2000 and XP clients. I have a logon script that I want to run on only XP clients. Is there a way I could modify the script to so it would check the os of the client and only run on xp clients? Below is my current script. Thanks.
option explicit
dim objNetwork, objShell, objFolder, objFolderItem
Const ssfPERSONAL = 5
Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ssfPERSONAL)
Set objFolderItem = objFolder.Self
objFolderItem.Name = "Users"
'msgbox objFolderItem.Name
'Clears Environment Cache
Set objNetwork = nothing
Set objShell = nothing
Set objFolder = nothing
Set objFolderItem = nothing
You can create a WMI filter for your GPO that filter ONLY your XP clients.
The query used for that is : [code:1]SELECT * FROM Win32_OperatingSystem WHERE Caption = 'Microsoft Windows XP Professionnel'[/code]
The problem with the WMI filter is that Windows 2000 does not support them. The Windows 2000 clients will ignore the filter (they don't even know what it is) and apply the policy.
You can however use the WMI query in the script to check...
[code:1]
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
dim strComputer
dim objWMIService
dim colItems
dim objItem
dim RunScript
RunScript = FALSE
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", _
"WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
for each objItem in colItems
If objItem.Caption = "Microsoft Windows XP Professional" then
RunScript = TRUE
End If
WScript.Echo objItem.Caption
Next
If RunScript = TRUE then
'Run the script
End If
[/code]