Results 1 to 3 of 3

Thread: Logon script to only run on XP clients

  1. #1
    mmartinez is offline Getting Started on GPanswers.com
    Join Date
    Dec 1969
    Posts
    4

    Default

    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

  2. #2
    mnpg is offline 10+ Helpful Posts 20+ Helpful Posts
    Join Date
    Dec 1969
    Posts
    22

    Default

    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]

  3. #3
    scottzaiss is offline 100+ Helpful Posts! 50+ Helpful Posts
    Join Date
    Dec 1969
    Posts
    118

    Default

    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]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Friendly URLs by vBSEO