Re: Win32_ComputerSystem
- From: "Scott McNairy \(MVP\)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Jul 2005 09:48:30 -0700
I am pretty sure that you will need to be an administrator to see that
information about other logged in user processes. The script below worked
for me when I connected to the remote server as an administrator. A good
test is to use Task Manager to see if your user account has rights to see
the owner of the other processes that are owned by different users.
--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure
"mrgadgetnz" <mrgadgetnz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C7712535-1D35-48DC-9262-C48BAFD8C227@xxxxxxxxxxxxxxxx
> Scott,
>
> Sorry to hijack the thread, but I've tried your code, and also the code in
> the scripting library for finding the owner of a process. This is great,
> only it doesn't return an owner for others' processes. I get the owner
> details back on processes owned by me, but just blank back on others'
> processors...
>
> Ideas?
>
> Thanks,
> Ben.
>
> "Scott McNairy (MVP)" wrote:
>
>> That property uses the GetUserName api documented here
>> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getusername.asp)
>> as you can see it has a couple of considerations that make it not so
>> reliable in the way you are seeing in determining who is currently logged
>> into the system. I think that the below script may give you better
>> results
>> as others have had success with it.
>>
>> set svc = getObject("winmgmts:root\cimv2")
>> set objEnum = svc.execQuery("select __relpath from win32_process where
>> caption = 'explorer.exe'")
>> for each obj in objEnum
>> set outParams = obj.ExecMethod_("GetOwner")
>> wscript.echo outParams.Domain & "\" & outParams.User
>> next
>>
>> --
>> Scott McNairy
>> Microsoft MVP - Windows Server Management Infrastructure
>>
>>
>> "Bart Perrier" <bart_perrier@xxxxxxxxxxx> wrote in message
>> news:%232iCraPfFHA.1248@xxxxxxxxxxxxxxxxxxxxxxx
>> >I appreciate both replies. I am considering the last logged in user as
>> > mentioned by Ato as a "best guess" if my Win32_ComputerSystem query is
>> > NULL.
>> > The more I think about it, the better it sounds...given the other
>> > result
>> > failed.
>> >
>> > I'm searching for another Class but haven't seen one for logged in
>> > user.
>> >
>> > Thanks for both ideas.
>> >
>> > Bart
>> >
>> >
>> > "Mike Long" <mlong35@xxxxxxxxx> wrote in message
>> > news:1120078092.298399.260530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >> An alternate method I use is environment strings.
>> >>
>> >> Set WshShell = WScript.CreateObject("Wscript.Shell")
>> >> Username = WshShell.ExpandEnvironmentStrings("%USERNAME%")
>> >>
>> >>
>> >> Mike
>> >> -Knowing it doesn't really answer the question, but trying to help
>> >> anyway
>> >>
>> >
>> >
>>
>>
>>
.
- Follow-Ups:
- Re: Win32_ComputerSystem
- From: mrgadgetnz
- Re: Win32_ComputerSystem
- References:
- Re: Win32_ComputerSystem
- From: mrgadgetnz
- Re: Win32_ComputerSystem
- Prev by Date: Search for event ID
- Next by Date: Re: DHCP and VBScripting
- Previous by thread: Re: Win32_ComputerSystem
- Next by thread: Re: Win32_ComputerSystem
- Index(es):
Relevant Pages
|