Jump to content

RegWrite with Windows 10


damon
 Share

Recommended Posts

I am having an issue with windows 10 and regwrite.  when i run my script it acts as though it has updated the registry but when i view the registry it has not updated the keys.  I added error checking to the script but it is not showing errors.  now if i remove #requireadmin i will get error 1 - unable to open requested key.

her is my code.

 

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Process.au3>

; Declared Variables
Global $userName = "user"
Global $userPassword = "Ktesting"
Global $autologin = "1"
Global $notification = "0"
Global $balloon = "0"


If @OSArch = "X64" Then
    Global $HKLM = "HKLM64"
Else
    Global $HKLM = "HKLM"
EndIf

; Looks for switch on program start
If $CmdLine[0] > 0 Then ; looks for switch on startup
    If $CmdLine[1] = "/boot" Then BootMachine()
Else
    MachineInstallation()
EndIf


; Setup Kiosk for first time
Func MachineInstallation()
    #RequireAdmin
    MsgBox (1, "Installation", "Starting Install")
    ; Add Program to Run registry Key
    RegWrite ($HKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "DL Kiosk", "REG_SZ", "c:\temp\DL Testing Kiosk\dl testing kiosk.exe /boot")
    If @error Then
        MsgBox (1, "error", @error)
    EndIf

    ; Add Automatic Logon Registry Key
    RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", $autologin)
        If @error Then
        MsgBox (1, "error", @error)
        EndIf

    RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $userName)
        If @error Then
        MsgBox (1, "error", @error)
        EndIf

    RegWrite ($HKLM & "\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $userPassword)
        If @error Then
        MsgBox (1, "error", @error)
        EndIf

    ; Pop Ups and Notification Center Registry
    RegWrite ("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", "REG_SZ", $notification)
        If @error Then
        MsgBox (1, "error", @error)
        EndIf

    RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableBalloonTips", $balloon)
        If @error Then
        MsgBox (1, "error", @error)
        EndIf

    MsgBox (1, "Installation", "Install completed")
EndFunc


Exit

 

EDIT:

i think i figured out my problem.  I was missing the space between Windows and NT.  user error, sorry.  

Edited by damon

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

  • Moderators

@damon you need to go over your script a little more closely:

  • The first call to RegWrite works just fine for me on Windows 10
  • The following 3 don't work because you misspelled the Key name - it is HKLM\SOFTWARE\Microsoft\Windows NT\ you missed the space
  • The next call works just fine for me on Windows 10
  • The last one fails because you didn't call it correctly
    • You neglected to include the Type parameter.
    • This parameter is not optional if you are going to specify a value.

After resolving all the mistakes, it runs just fine for me.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 8 months later...

I have a few issues with this as well, but I'm just using "Case $msg" for calling the Regwrite, is there an issues with that?

EXAMPLE

Case $msg = $b_varsle_install
            RegWrite("HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "REG_DWORD", "0")
            RegWrite("HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "REG_DWORD", "2")
            RegWrite("HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "REG_DWORD", "0")
            RegWrite("HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "REG_DWORD", "3")

Nevermind, this option does not work with Windows 10 Home anymore.

Edited by flaritycat
Link to comment
Share on other sites

@flaritycat - Although policies no longer work in Windows 10, just for future reference remember to use HKLM for accessing 32-bit keys and HKLM64 for 64-bit keys for example:

Local $sHKLM = @OSArch = 'x64' ? 'HKLM64' : 'HKLM'

RegWrite($sHKLM & "\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "REG_DWORD", "0")
RegWrite($sHKLM & "\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "REG_DWORD", "2")
RegWrite($sHKLM & "\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "REG_DWORD", "0")
RegWrite($sHKLM & "\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "REG_DWORD", "3")

 

Link to comment
Share on other sites

  • 2 years later...

I am still having trouble getting RegWrite to work with win10.   The code runs, but the system variable does not change.   Any idea what I need to do to make this work?   Thanks!

RegWrite('HKLM64\SYSTEM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'CDS_LIC_FILE', 'Reg_sz', '5280@usshkpmpengap09.emrsn.org')
RegWrite('HKLM64\SYSTEM\SYSTEM\ControlSet001\Control\Session Manager\Environment', 'CDS_LIC_FILE', 'Reg_sz', '5280@usshkpmpengap09.emrsn.org')

Link to comment
Share on other sites

  • Developers
17 minutes ago, Earthshine said:

.....and run Scite editor to run as admin first. try that

No need to do that first..right?

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.
  :)

Link to comment
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
 Share

×
×
  • Create New...