--J.LO-- Posted October 2, 2006 Posted October 2, 2006 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?
lod3n Posted October 2, 2006 Posted October 2, 2006 (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 October 2, 2006 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
herewasplato Posted October 2, 2006 Posted October 2, 2006 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 EndFuncI changed your last EndIf to EndFunc. (I did not test under the OP's conditions.) [size="1"][font="Arial"].[u].[/u][/font][/size]
lod3n Posted October 2, 2006 Posted October 2, 2006 Damn you Scite4AutoIt AutoComplete and my inability to proofread! Thanks, I've fixed the post. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
lod3n Posted October 2, 2006 Posted October 2, 2006 Might also look at psloggedon from SysInternals. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now