From: mrgadgetnz on
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(a)hotmail.com> wrote in message
> news:%232iCraPfFHA.1248(a)TK2MSFTNGP12.phx.gbl...
> >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(a)gmail.com> wrote in message
> > news:1120078092.298399.260530(a)g14g2000cwa.googlegroups.com...
> >> 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
> >>
> >
> >
>
>
>
From: Scott McNairy (MVP) on
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(a)discussions.microsoft.com> wrote in message
news:C7712535-1D35-48DC-9262-C48BAFD8C227(a)microsoft.com...
> 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(a)hotmail.com> wrote in message
>> news:%232iCraPfFHA.1248(a)TK2MSFTNGP12.phx.gbl...
>> >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(a)gmail.com> wrote in message
>> > news:1120078092.298399.260530(a)g14g2000cwa.googlegroups.com...
>> >> 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
>> >>
>> >
>> >
>>
>>
>>


From: mrgadgetnz on
Yes, it does appear that you do indeed need admin priviledges. Is there any
way to raise the priviledges of a script (from within the script)? I don't
want to give this user Admin priviledges, but I want them to be able to
see/kill specific tasks...

Thanks,
Ben.

"Scott McNairy (MVP)" wrote:

> 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(a)discussions.microsoft.com> wrote in message
> news:C7712535-1D35-48DC-9262-C48BAFD8C227(a)microsoft.com...
> > 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(a)hotmail.com> wrote in message
> >> news:%232iCraPfFHA.1248(a)TK2MSFTNGP12.phx.gbl...
> >> >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(a)gmail.com> wrote in message
> >> > news:1120078092.298399.260530(a)g14g2000cwa.googlegroups.com...
> >> >> 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
> >> >>
> >> >
> >> >
> >>
> >>
> >>
>
>
>
From: Scott McNairy (MVP) on
I am 95% certain that you need to be an admin to do that to other user owned
processes, however adding this line of code here would be worth the
experimentation.

svc.security_.privileges.AddAsString "SeDebugPrivilege", true

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure


"mrgadgetnz" <mrgadgetnz(a)discussions.microsoft.com> wrote in message
news:4D673188-195B-4190-B97D-CBAB779D8EE3(a)microsoft.com...
> Yes, it does appear that you do indeed need admin priviledges. Is there
> any
> way to raise the priviledges of a script (from within the script)? I
> don't
> want to give this user Admin priviledges, but I want them to be able to
> see/kill specific tasks...
>
> Thanks,
> Ben.
>
> "Scott McNairy (MVP)" wrote:
>
>> 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(a)discussions.microsoft.com> wrote in message
>> news:C7712535-1D35-48DC-9262-C48BAFD8C227(a)microsoft.com...
>> > 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(a)hotmail.com> wrote in message
>> >> news:%232iCraPfFHA.1248(a)TK2MSFTNGP12.phx.gbl...
>> >> >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(a)gmail.com> wrote in message
>> >> > news:1120078092.298399.260530(a)g14g2000cwa.googlegroups.com...
>> >> >> 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
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>