Jump to content
xCROv

RegWrite() not writing some reg keys?

Recommended Posts

xCROv

I'm having a strange issue where some registry keys are not being completed but the rest in the function are. I am running on a local admin account and am able to update WSUS reg keys but not Winlogon keys for auto login. Has anyone run into this issue before? I have @RequireAdmin running at the top of my script and am kinda out of ideas.

 

Works

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "AcceptTrustedPublisherCerts", "REG_DWORD", "00000001")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "ElevateNonAdmins", "REG_DWORD", "00000000")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "WUServer", "REG_SZ", "http://10.1.1.10:8530")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "WUStatusServer", "REG_SZ", "http://10.1.1.10:8530")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "DisableOSUpgrade", "REG_DWORD", "00000001")

___

Doesn't work

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "username")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "hunter2")

 

Share this post


Link to post
Share on other sites
xCROv
1 minute ago, Jos said:

Probably related to 32/64 bits. Look in the wowxxxx tree for those saved keys.

Jos

I seriously just saw your post suggesting the exact same thing from 2 years ago and that's the issue. There is a dll call you can make to prevent it doing this that I am going to hunt down and throw in there but it looks like that's the problem. Thanks!

 

https://www.autoitscript.com/forum/topic/183292-regwrite-does-not-work-properly/?do=findComment&comment=1316379

Share this post


Link to post
Share on other sites
ViciousXUSMC

Disable Wow64Redirection, or just use HKLM64

Share this post


Link to post
Share on other sites
Subz
Global $sHKLM = @OSArch = "x64" ? "HKLM64" : "HKLM"
    RegWrite($sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")
    RegWrite($sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1")
    RegWrite($sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "username")
    RegWrite($sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "hunter2")

 

Share this post


Link to post
Share on other sites
kosamja
58 minutes ago, Subz said:
Global $sHKLM = @OSArch = "x64" ? "HKLM64" : "HKLM"

 

What to use if script is compiled as 64 bit, HKLM or HKLM64?

Share this post


Link to post
Share on other sites
Subz
Posted (edited)

If its compiled as 64 bit you can still use either HKLM or HKLM64, I don't tend to ever compile any 64 bit scripts since haven't found any use for them.  If I need to run 64 bit programs I use:

Global $iCmdProcess
If @OSArch = "x64" Then
    ;~ 64 bit Process
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turns Off 64 Bit Redirection
        $iCmdProcess = Run("cmd.exe /k")
    DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turns On 64 Bit Redirection
Else
    ;~ 32 bit Process
    $iCmdProcess = Run("cmd.exe /k")
EndIf

 

Edited by Subz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×