MrChris Posted July 24, 2006 Share Posted July 24, 2006 (edited) Would I be able to retrieve a logged in users GUID ID from the reg and set it as a var? for example my current GUID ID is S-1-5-21-3783412348-3147957303-627458716-1003 I was thinking of setting that as a var. I have a Key and a value that I need to be dynamic but gets stored in the HKU\S-1-5-21-3783412348-3147957303-627458716-1003 Key. The closest I could come up with is below but im not sure if this will work on any XP/2003 system. This is just a test to see if it will retrieve the correct code. All I really need is to be able to set that KEY as the $var. Even so I kinda need to full path to be the var. not just the GUID. For $i= 1 to 10 $var = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System Provider", $i) If @error <> 0 then ExitLoop MsgBox(4096, "SubKey #" & $i & " under HKU\Software\Microsoft\Protected Storage System Provider: ", $var) Next Thanks, MrChris Edited July 24, 2006 by MrChris Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2006 Share Posted July 24, 2006 (edited) Would I be able to retrieve a logged in users GUID ID from the reg and set it as a var? for example my current GUID ID is S-1-5-21-3783412348-3147957303-627458716-1003 I was thinking of setting that as a var. I have a Key and a value that I need to be dynamic but gets stored in the HKU\S-1-5-21-3783412348-3147957303-627458716-1003 Key. The closest I could come up with is below but im not sure if this will work on any XP/2003 system. This is just a test to see if it will retrieve the correct code. All I really need is to be able to set that KEY as the $var. Even so I kinda need to full path to be the var. not just the GUID. For $i= 1 to 10 $var = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System Provider", $i) If @error <> 0 then ExitLoop MsgBox(4096, "SubKey #" & $i & " under HKU\Software\Microsoft\Protected Storage System Provider: ", $var) Next Thanks, MrChris This might be usefull for me too, so I did some preliminay Googling. I came up with the following statement: "The GetUserNameEx() call can be made to retrieve the current user's GUID or other unique information,..." But I haven't tracked down using that GetUserNameEx() Windows API yet. Will have more resources available later. Edit: Looks like the "NameUniqueId -- A GUID string that the IIDFromString function returns (for example, {4fa050f0-f561-11cf-bdd9-00aa003a77b6})." would be the NameFormat desired from the GetUserNameEx() function. Edited July 24, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
bluebearr Posted July 24, 2006 Share Posted July 24, 2006 Well, if you are not adverse to using WMI, I ripped this off from a VBScript (http://www.codecomments.com/archive299-2005-6-515041.html). Requires beta. $oWMI = ObjGet("winmgmts://./root/cimv2") $oUser = $oWMI.Get("Win32_UserAccount.Domain='" & @LogonDomain & "'" _ & ",Name='" & @UserName & "'") $sUserSID = $oUser.SID MsgBox(0, "UserSID", $sUserSID) BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
MrChris Posted July 24, 2006 Author Share Posted July 24, 2006 OK This is what I have come up with so far but am having trouble getting the syntax correct. The problem I think is with the $guid var in the RegWrite function. Maybe? The below key in RegEnumKey is the only place in the Reg that I could find the current logged in users GUID from. #NoTrayIcon $i = 1 $guid = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System Provider", $i) ;MsgBox(4096, "User GUID" & $i & " Your User GUID is: ", $guid) ; Sample RegWrite('HKEY_USERS' $guid & '\Software\KEY\SUBKEY','DATA','REG_DWORD','VALUE') RegWrite('HKEY_USERS' $guid & '\Software\KEY\SUBKEY','DATA','REG_DWORD','VALUE1') RegWrite('HKEY_USERS' $guid & '\Software\KEY\SUBKEY','username','REG_SZ',@UserName) Thanks in advance, MrChris Link to comment Share on other sites More sharing options...
MrChris Posted July 24, 2006 Author Share Posted July 24, 2006 Well, if you are not adverse to using WMI, I ripped this off from a VBScript (http://www.codecomments.com/archive299-2005-6-515041.html). Requires beta. $oWMI = ObjGet("winmgmts://./root/cimv2") $oUser = $oWMI.Get("Win32_UserAccount.Domain='" & @LogonDomain & "'" _ & ",Name='" & @UserName & "'") $sUserSID = $oUser.SID MsgBox(0, "UserSID", $sUserSID) Sweet thanks, I will give it a shot. MrChris Link to comment Share on other sites More sharing options...
bluebearr Posted July 24, 2006 Share Posted July 24, 2006 (edited) Try changing this: RegWrite('HKEY_USERS' $guid & '\Software\KEY\SUBKEY','DATA','REG_DWORD','VALUE')oÝ÷ ÚÚ-+ºÚ"µÍYÕÜ]J ÌÎNÒÑVWÕTÑTÉÌLÉÌÎNÈ [È ÌÍÙÝZY [È ÌÎNÉÌLÔÛÙØIÌLÒÑVIÌLÔÕPÑVIÌÎNË ÌÎNÑUIÌÎNË ÌÎNÔQ×ÑÓÔ ÌÎNË ÌÎNÕSQIÌÎNÊ of course, VALUE should be a DWORD. Edited July 24, 2006 by bluebearr BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
MrChris Posted July 24, 2006 Author Share Posted July 24, 2006 Right on. I knew it was something I was missing. Thats what I get for trying to pull an all-nighter on this project. Thanks again. MrChris 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