WMI listing processes and user as login user not admin local

Discussion in 'Scripting' started by Roland, Jun 14, 2007.

  1. Roland

    Roland Guest

    the problem is - i will look on a terminal server as a user not as a admin,
    who runs as examble the internet explorer. but the script showns me my own
    explorer but not the name of the user which opened the internet explorer at
    this terminal server.
    i see the count of the users but not the names.

    see:

    strProcess = "iexplore.exe"
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process
    Where Name = '" & strProcess & "'")

    For Each objProcess in colProcessList
    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
    Wscript.Echo "Process " & objProcess.Name & " is owned by " _
    & strUserDomain & "\" & strNameOfUser & "."
    Next




    if i ask a remote terminalserver I have a script wich works fine but no
    local.


    Const WbemAuthenticationLevelPktPrivacy = 6
    strProcess = "iexplore.exe"
    strComputer = "192.168.199.199"
    strNamespace = "root\cimv2"
    strUser = "administrator"
    strPassword = "xxxxxxx"

    Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWMIService = objwbemLocator.ConnectServer _
    (strComputer, strNamespace, strUser, strPassword)
    objWMIService.Security_.authenticationLevel =
    WbemAuthenticationLevelPktPrivacy
    Set colItems = objWMIService.ExecQuery ("Select * from Win32_Process Where
    Name = '" & strProcess & "'")
    For Each objItem in ColItems
    Return = objItem.GetOwner(strNameOfUser)
    colProperties = objitem.GetOwner(strNameOfUser,strUserDomain)
    Wscript.Echo strNameOfUser & "."
    next
     
    Roland, Jun 14, 2007
    #1
    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.