jp10558 Posted May 7, 2007 Posted May 7, 2007 I have a problem where I'm trying to set one particular setting for PuTTY, specifically, turn on X Forwarding in the default settings. The setting is stored in the registry, but of course, not under HKCU, no it's under HKey_Users\{SID} ... So to set it, I have to find out the users SID and then I can write to it via RegWrite... Any ideas? Or even a better way to set PUTTY default settings?
arcker Posted May 7, 2007 Posted May 7, 2007 by wmi -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
jp10558 Posted May 7, 2007 Author Posted May 7, 2007 I guess to be more specific - how do I do that? There is no WMI in the AutoIT Help. How do I get the SID into my AutoIT script as a variable so I can do the RegWrite described?
PsaltyDS Posted May 7, 2007 Posted May 7, 2007 From 'Hey, Scripting Guy!': How Can I Determine the SID for a User Account?The linked solution is in Visual Basic Script, but can be used in AutoIT if you have learned AutoIt's COM/OBJ functions.Let the help file reading begin! 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
evilertoaster Posted May 7, 2007 Posted May 7, 2007 According to the documentation the settings are stored in HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
Selmak Posted May 7, 2007 Posted May 7, 2007 IIRC, you can only write to the current user's registry anyway. If you're thinking of changing the setting for more than one user, 'fraid that won't work even if you know the SID because the hives in question aren't loaded until the owner logs-on. OTOH, for the logged-on user, HKCU is all you need.
PsaltyDS Posted May 7, 2007 Posted May 7, 2007 (edited) IIRC, you can only write to the current user's registry anyway. If you're thinking of changing the setting for more than one user, 'fraid that won't work even if you know the SID because the hives in question aren't loaded until the owner logs-on.OTOH, for the logged-on user, HKCU is all you need.You can write to another user's registry, providing you have the needed admin privileges. Each user's hive is actually NTUser.dat in their profile directory. The link to that hive in RegEdit under HKU (which is displayed by SID) is just a link to the NTUser.dat in their profile. But the only easy way to read/write to NTUser.dat for another user is via the registry link at HKU\{SID}. BTW, you'll want that setting in HKU\.DEFAULT so it is included automatically for new users, who just get a copy of .DEFAULT's NTUser.dat in their profile the first time they logon. Edited May 7, 2007 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
PaulIA Posted May 7, 2007 Posted May 7, 2007 I have a problem where I'm trying to set one particular setting for PuTTY, specifically, turn on X Forwarding in the default settings. The setting is stored in the registry, but of course, not under HKCU, no it's under HKey_Users\{SID} ... So to set it, I have to find out the users SID and then I can write to it via RegWrite... Any ideas? Or even a better way to set PUTTY default settings?If you don't feel like reinventing the wheel, grab a copy of Auto3Lib from my signature and run this: #include <A3LSecurity.au3> Opt("MustDeclareVars", 1) Global $sUser, $aName $sUser = InputBox("Security Demo", "Enter Network Name:", "Administrator", "", 200, 130) if @Error <> 0 then Exit $aName = _Security_LookupAccountName($sUser) if @Error = 0 then _Lib_ConsoleWrite("SID .........: " & $aName[0] ) _Lib_ConsoleWrite("Domain ......: " & $aName[1] ) _Lib_ConsoleWrite("SID Type ....: " & _Security_SidTypeStr($aName[2])) else _Lib_ConsoleWrite("Invalid user name") endif Auto3Lib: A library of over 1200 functions for AutoIt
arcker Posted May 8, 2007 Posted May 8, 2007 hi Paul i've just thought about your library tsss i use this for sid why did i not mention it -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
jp10558 Posted May 8, 2007 Author Posted May 8, 2007 Thanks all, but I found a better way for my purposes - which is I noticed that PuTTY has a command line switch for this ... I feel stupid, but it's doing what I need.
cardguy1000 Posted December 27, 2007 Posted December 27, 2007 Incase anyone is interested I built a function to do this. Func _getSID($username, $domain, $servername = ".") Local $objWMIService = ObjGet("winmgmts:\\" & $servername & "\root\cimv2") Local $security = $objWMIService.Security_ $security.ImpersonationLevel = 3 Local $objAccount = $objWMIService.Get("Win32_UserAccount.Name='" & $username & "',Domain='" & $domain & "'") Return $objAccount.SID EndFunc $SID = _getSID("administrator", "TESTDOMAIN") Neutro 1
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