Sign in to follow this  
Followers 0
--J.LO--

How to find User on Console 0

5 posts in this topic

Hi,

i desperately try to find a script or tool that shows the user logged into console 0 of a machine. I'm running an autoit script within a service account so @username will return the user of that account.

i want to know if real (human) user has logged onto the machine and get his name or id..

THX

I suggest this could be an extension for UDF compinfo.au3?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

func _getLocalUser($strComputer)
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
    if isObj($objWMIService) then
        $colComputer = $objWMIService.ExecQuery ("Select UserName from Win32_ComputerSystem")
        For $objComputer in $colComputer
            return $objComputer.UserName
        Next 
    EndIf
    return 0
EndFunc

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

MsgBox(0, "", _getLocalUser("-"))
MsgBox(0, "", @UserName)

Func _getLocalUser($strComputer)
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
    If IsObj($objWMIService) Then
        $colComputer = $objWMIService.ExecQuery ("Select UserName from Win32_ComputerSystem")
        For $objComputer In $colComputer
            Return $objComputer.UserName
        Next
    EndIf
    Return 0
EndFunc
I changed your last EndIf to EndFunc.

(I did not test under the OP's conditions.)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0