phughes64 Posted August 27, 2008 Share Posted August 27, 2008 Hi All, Is there any way that I can capture a user's windows username? Many thanks Paul P.S. sorry if this question has been posted several times before. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 27, 2008 Share Posted August 27, 2008 @UserName = ID of the currently logged on user. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
phughes64 Posted August 27, 2008 Author Share Posted August 27, 2008 I know how to establish a variable - but how can I pull the username without requiring the user to manually type/select the username? Link to comment Share on other sites More sharing options...
MadBoy Posted August 27, 2008 Share Posted August 27, 2008 (edited) I know how to establish a variable - but how can I pull the username without requiring the user to manually type/select the username? @username isn't variable in autoit $variable_name = @username MsgBox(0,"TEST", $variable_name) MsgBox(0,"TEST2", @username) Reason for edit: Fixed MessageBox to MsgBox. Been using too much C# latly Edited August 27, 2008 by MadBoy My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
phughes64 Posted August 27, 2008 Author Share Posted August 27, 2008 many thanks and forgive the stupidity lol Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 27, 2008 Share Posted August 27, 2008 MsgBox(0, "User Full Name", GetFullName(@UserName)) Func GetFullName($sUserName) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Return $objItem.FullName Next Else Return SetError(1, 0, "") EndIf EndFunc ;==>GetFullName Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Sedorox Posted September 4, 2008 Share Posted September 4, 2008 MsgBox(0, "User Full Name", GetFullName(@UserName)) Func GetFullName($sUserName) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Return $objItem.FullName Next Else Return SetError(1, 0, "") EndIf EndFunc ;==>GetFullName Mega Thanks! I was looking on how to pull username, and then I come across this tidbit. The guy I'm working with and myself were just talking about what to do with grabbing the full name. It's amazing how one can come across this kind of thing! Thanks again!! Link to comment Share on other sites More sharing options...
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