Luigi Posted September 18, 2014 Share Posted September 18, 2014 (edited) Hi Forum, I know... there are many ways to get a list (array) with all windows's users... This query in WMI is good? Always work? What I want? Get an array with all windows's users. The windows's default users is not wanted (like 'All Users', 'Default', 'Default User', etc). Best regards, Detefon SELECT LocalPath FROM Win32_UserProfile WHERE SID LIKE 'S-1-5-21%' #include <Array.au3> Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $arrName = StringSplit("LocalPath", ",", 2) Local $colItems = $objWMIService.ExecQuery("SELECT LocalPath FROM Win32_UserProfile WHERE SID LIKE 'S-1-5-21%'", "WQL", 0x10 + 0x20) Local $Result = '' Local $sLocalPath Local $aUsers[1] Local $sUsersFolder = _GetUsersFolder() If IsObj($colItems) Then For $objItem In $colItems For $jj = 0 To UBound($arrName) - 1 $sLocalPath = StringReplace(Execute("$objItem." & $arrName[$jj]), $sUsersFolder & "\", "") _ArrayAdd($aUsers, $sLocalPath) Next Next _ArrayDelete($aUsers, 0) _ArrayDisplay($aUsers, "Users") EndIf Func _GetUsersFolder() Local $arr = StringSplit(@DesktopCommonDir, "\", 2) Return $arr[0] & "\" & $arr[1] EndFunc ;==>_GetUsersFolder Edited September 18, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
Danyfirex Posted September 18, 2014 Share Posted September 18, 2014 Did you mean user Profiles or user Accounts? Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 yes, only user's name. Visit my repository Link to comment Share on other sites More sharing options...
Danyfirex Posted September 18, 2014 Share Posted September 18, 2014 So your code work? WMI is good. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 (edited) Work, for me, the doubt is: it always work? I'm not sure here: SELECT LocalPath FROM Win32_UserProfile WHERE SID LIKE 'S-1-5-21%' If all users's guid starting with 's-1-5-21%' always return the users, that is que question! 8D Edited September 18, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
MikahS Posted September 18, 2014 Share Posted September 18, 2014 Work, for me, the doubt is: it always work? I'm not sure here: SELECT LocalPath FROM Win32_UserProfile WHERE SID LIKE 'S-1-5-21%' If all users's guid starting with 's-1-5-21%' always return the users, that is que question! 8D Yes, I'm pretty sure. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Danyfirex Posted September 18, 2014 Share Posted September 18, 2014 Yes should work. or use this registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileList saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 Yes should work. or use this registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileList hum... others alternatives! I like this! ^^ Thank you Danyfirex ^^ Yes, I'm pretty sure. Thank you MikahS. ^^ Visit my repository Link to comment Share on other sites More sharing options...
j0kky Posted September 18, 2014 Share Posted September 18, 2014 (edited) Work, for me, the doubt is: it always work? Obviously your script doesn't work if WMI is disabled. Edited September 18, 2014 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
mikell Posted September 18, 2014 Share Posted September 18, 2014 The WMI class Win32_UserProfile doesn't exist on XP Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 j0kky, you talk about the point! I want know how to verify the status, start and stop the wmi! Yes, you are write, I presume the WMI is enable... But, I unknow how check this... Visit my repository Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 The WMI class Win32_UserProfile doesn't exist on XP mikell, it's important for my work, thanks ^^ Visit my repository Link to comment Share on other sites More sharing options...
MikahS Posted September 18, 2014 Share Posted September 18, 2014 (edited) Thank you MikahS. ^^ No problem Also, way to check if WMI is enabled (I'm pretty sure) $oWMIService = ObjGet("winmgmts:\\.\root\cimv2") If IsObj($oWMIService) Then Edited September 18, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
jguinch Posted September 18, 2014 Share Posted September 18, 2014 #Include <Array.au3> $a = _LocalAccounts_GetUserList() _ArrayDisplay($a) Func _LocalAccounts_GetUserList() Local $sComputerName = @ComputerName, $aFilter[1] = ["user"], $aResult[1], $oUser Local $oComputer = ObjGet("WinNT://" & $sComputerName) If NOT IsObj($oComputer) Then Return SetError(2, 0, 0) $oComputer.Filter = $aFilter For $oUser In $oComputer Redim $aResult[ UBound($aResult) + 1] $aResult[ UBound($aResult) - 1] = $oUser.Name Next $aResult[0] = UBound($aresult) - 1 Return $aResult EndFunc ; ===> _LocalAccounts_GetUserList Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
kylomas Posted September 18, 2014 Share Posted September 18, 2014 Datefon, A non-WMI way... #include <File.au3> ;#include <array.au3> local $aUsers = _FileListToArrayRec('C:\users','*',$FLTAR_FOLDERS) for $1 = 1 to $aUsers[0] if not stringregexp($aUsers[$1],'All Users(\|)?|Default( User)?(\|)?|Public(/|)?') then ConsoleWrite($aUsers[$1] & @CRLF) next This is good on Win7. The directory structure is different on XP and may be different on Vista and Win8. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jguinch Posted September 18, 2014 Share Posted September 18, 2014 What about Win32_Account ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
kylomas Posted September 18, 2014 Share Posted September 18, 2014 @jguinch - If that is directed at me then I don't know what Win32_Account is. Possibly because I'm using the Home version of Win7 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Gianni Posted September 18, 2014 Share Posted September 18, 2014 (edited) one more way (without wmi) #include <array.au3> Local $DOS_out ; Returns members of Users group (remove first 6 unwanted lines) $iPID = Run(@ComSpec & ' /c NET LOCALGROUP Users | MORE /E +6', "", @SW_HIDE, 2) Do ; wait that dos has finished $DOS_out &= StdoutRead($iPID) Until @error ; Parse members of Users group from DOS output $admins = StringSplit(StringStripWS($DOS_out, 7), @CR, 2) _ArrayPop($admins); remove last unwanted line _ArrayDisplay($admins) ; show Users group members edit: change the group name in this line to select members of other groups: $iPID = Run(@ComSpec & ' /c NET LOCALGROUP Users | MORE /E +6', "", @SW_HIDE, 2) Edited September 18, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
kylomas Posted September 18, 2014 Share Posted September 18, 2014 @Chimp - I get this as output (Win7 - Home)... Nancy NT AUTHORITYAuthenticated Users NT AUTHORITYINTERACTIVE Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Luigi Posted September 18, 2014 Author Share Posted September 18, 2014 I hope that Google translator help me to say what I want. I am very happy to see that so many people reply this topic, and especially with different ways of doing the same thing! Particularly I read each code carefully and let the imagination fly, thinking of other alternatives, other scripts, this is really cool. I think unfair to choose one of the answers, to give the topic is closed, I can not do that. Choosing one is not an alternative for me, all are great. All options solved my problem. Thank you: @Danyfirex, @MikahS, @j0kky, @mikell, @jguinch, @kylomas, @Chimp Visit my repository 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