xinx Posted March 3, 2012 Share Posted March 3, 2012 Hi all.I'm having a problem with writing something to the registryRegWrite("HKEY_LOCAL_MACHINE\Software\xinx\management\Users\" & $SelectedUserType & "\" & $sUser, $FolderType, "REG_SZ", $Folder)If the $SelectedUserType is 'System Administrators' then the result is a little unexpected. Instead of showing as: HKEY_LOCAL_MACHINE\Software\xinx\management\Users\System Administrators\Admin like I should see, it shows as HKEY_LOCAL_MACHINE\Software\xinx\management\Users\System\Administrators\Admin (which means it has basically split the System Administrators in two and made the variable into two reg keys).It works if the $SelectedUserType is 'SystemAdmins' for example, but just doesn't seem to like it if the variable has a space...I hope this makes sense, and any help is much appreciated! :-) Link to comment Share on other sites More sharing options...
DW1 Posted March 3, 2012 Share Posted March 3, 2012 On Win7 64 I cannot repro the issue either... I get the expected result. What OS are you working with? Are you using the latest version of AutoIt? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
xinx Posted March 3, 2012 Author Share Posted March 3, 2012 (edited) Ack sorry, tiredness!Firstly, thank you for your quick responses Secondly, I forgot to say that this runs from another PC and is meant to write to the registry on the server.It's a bit difficult to explain how this all works, but if the program is run and it detects it is not running on the server (i.e., on a client PC) it then runs this command:$RemoteProfile = "C:ManagementRemoteCreateProfile.exe" $Sharename = Test $PsExecCommand = 'exePsExec ' & $server & ' -s' & ' "' & $RemoteProfile & '" ' & $SelectedUserType & ' ""' & $sUser & ' "' & $ProfileFolder & '" ' & $Sharename & ' Profile' $iValue = Run($PsExecCommand, "", @SW_HIDE)The code in RemoteCreateProfile is:$SelectedUserType = $CmdLine[1] $sUser = $CmdLine[2] $Folder = $CmdLine[3] $ShareName = $CmdLine[4] $FolderType = $CmdLine[5] $iValue = DirCreate($Folder) If $iValue = 1 Then If @OSArch = "X86" Then RunWait('RP32.exe "' & $SelectedUserType & '" "' & $sUser & '" "' & $FolderType & '" "' & $Folder & '"') Else RunWait('RP64.exe "' & $SelectedUserType & '" "' & $sUser & '" "' & $FolderType & '" "' & $Folder & '"') EndIf EndIfAnd in RP32 (or RP64) the code is:$SelectedUserType = $CmdLine[1] $sUser = $CmdLine[2] $FolderType = $CmdLine[3] $Folder = $CmdLine[4] RegWrite("HKLM64SoftwarexinxmanagementUsers" & $SelectedUserType & "" & $sUser, $FolderType, "REG_SZ", $Folder)Additional: I tried using the single quotes as you asked, but strangely it now shows as 'System' (with the single quotes) in the registry! :-/ Weird. Edited March 4, 2012 by xinx Link to comment Share on other sites More sharing options...
xinx Posted March 3, 2012 Author Share Posted March 3, 2012 Hi danwilli, Just checked and made sure that I am using the latest version (just downloaded alatest AutoIT and recompiled the scripts), but still no joy. The O/s that it is running from is 32-bit Windows XP, and it is writing to 64-bit Windows Server 2008. It works if the $SelectedUserType is only one word which is the part I do not understand. Link to comment Share on other sites More sharing options...
water Posted March 3, 2012 Share Posted March 3, 2012 When writing to the Registry on a 64 bit system you need to replace HKLM with HKLM64. According to the help file: "When running on 64-bit Windows if you want to write a key or value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64." My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
xinx Posted March 3, 2012 Author Share Posted March 3, 2012 (edited) Hi water,Thanks for you input. However, when run locally on the server using HKLM it does not cause a problem, i.e., the script on the server doesn't have HKLM64 in it either. Only when running the program from a remote PC does this problem occur Edit: I thought it was worth a shot anyway, changed HKLM to HKLM64 but still has the same results. Edited March 3, 2012 by xinx Link to comment Share on other sites More sharing options...
xinx Posted March 13, 2012 Author Share Posted March 13, 2012 Just in case anyone reads this thread, the simple resolution was to concatenate the usertype of 'System Admins' to 'SystemAdmins'. Worked a treat 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