bobbintb Posted October 30, 2009 Posted October 30, 2009 i need to get the SID to help me gleam info from the registry properly and i read you can get it with EnvGet() but i don't see a list of variable to use so i cant find it. is there any function to get the SID or will i have to make something up, which will more than likely be ineffective?
Developers Jos Posted October 30, 2009 Developers Posted October 30, 2009 Its easy to know what variables are available for envget(): Just open an CMD session and type the set command. Try this func to retrive the current users SID: ConsoleWrite(GetUserSID(@ComputerName,@UserName) & @CRLF) Func GetUserSID($ComputerName,$Username) Dim $UserSID, $oWshNetwork, $oUserAccount $objWMIService = objGet( "winmgmts:{impersonationLevel=impersonate}!//" & $ComputerName & "/root/cimv2") $oUserAccounts = $objWMIService.ExecQuery("Select Name, SID from Win32_UserAccount") For $oUserAccount In $oUserAccounts If $Username = $oUserAccount.Name Then Return $oUserAccount.SID Next Return "" EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
trancexx Posted October 30, 2009 Posted October 30, 2009 Since Winmgmt service can be stopped or paused for some reason thus causing the failure of the code posted by Jos, you can use _Security__LookupAccountName() function to get wanted information. Array is returned and you want the first element of it ($array[0]). ♡♡♡ . eMyvnE
bobbintb Posted October 30, 2009 Author Posted October 30, 2009 ah ok. i knew there had to be something. thanks.
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