Win32_Process.GetOwnerdoes not return owner information for non- adminstrative users

Discussion in 'Scripting' started by Keith Young, Oct 18, 2004.

  1. Keith Young

    Keith Young Guest

    I use the following script to retrieve all processes that are running on a
    Windows 2000 Terminal Server.
    It supposes to get all the process names and process owners. However it
    only able to get owner information for users that are memebers of the
    administrators group,
    but not for non administrative users. I attached a partial output of this
    script. The process owners information are missing. I ran this script
    under the security context of administrator account. Any help will be
    greatly appreciated. Thanks very much.

    strComputer = "."
    Dim UserName

    Const ForAppending = 2
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile("c:\perflogs\process.txt",
    ForAppending, True)

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")
    objTextFile.WriteLine DateTime

    For Each objProcess in colProcess
    Return = objProcess.GetOwner(UserName)
    If Return <> 0 Then
    objTextFile.WriteLine objProcess.Name
    objTextFile.WriteLine objProcess.Name & vbtab & vbtab & UserName
    End If
    -------------Partial Output ----------
    ssonsvr.exe SYSTEM
    explorer.exe Administrator
    wuauclt.exe Administrator
    VMwareTray.exe Administrator
    icabar.exe Administrator
    rdpclip.exe <--------------Username missing (regular user)
    explorer.exe <--------------Username missing
    IEXPLORE.EXE <-------------Username missing
    rdpclip.exe DBrown <-------------Member of administrators group
    explorer.exe DBrown <-------------Member of administrators group
    IEXPLORE.EXE DBrown <-------------Member of administrators group
    rdpclip.exe <--------------Username missing (regular user)
    explorer.exe <--------------Username missing
    IEXPLORE.EXE <-------------Username missing
    Keith Young, Oct 18, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.