damon

RegWrite with Windows 10

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



@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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted

You can write in windows 10 with System user privilege.... use psexec tool.

Ex: psexec -i -s yourautoitscript.exe

Share this post


Link to post
Share on other sites

#6 ·  Posted

@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")

 

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

  • Similar Content

    • DLS
      By DLS
      I have a working script that changes the core affinity and process priority of multiples of a specific application I have running.  
      I have that part figured out.

      I would like to make a little modification to it.

      Windows10 introduced virtual desktops.  I am trying to have different core affinity and priority of processes on the visible and non-visible desktops.  
      What I need is a bool function that could be described as IsWindowOnCurrentDesktop($hWnd).  I have searched the winAPI.au3 but I do not believe anything like that exists built it.
      I have searched multiple places before asking for help. I found a Microsoft supplied example of the function I need using C#, but I am unfamiliar with C# to a degree that I cannot port the system call over.
      https://blogs.msdn.microsoft.com/winsdk/2015/09/10/virtual-desktop-switching-in-windows-10/
      Help is appreciated but not expected.  Thanks in advanced.   In the meantime I will be learning C# syntax and class structure.
    • therks
      By therks
      Does anybody know how I would go about getting the window title bar colour on Windows 10? I tried using _WinAPI_GetSysColor, and manually reading the registry (HKCU\Control Panel\Colors, ActiveTitle) but in either case I get the same (0x99B4D1, wrong) result.
      RegRead('HKCU\Control Panel\Colors', 'ActiveTitle') ; Returns 153 180 209 (aka 99B4D1) _WinAPI_GetSysColor ($COLOR_ACTIVECAPTION) ; Returns 0xD1B499 (aka 99B4D1)  
    • therks
      By therks
      As the title says, does anyone know of a way to open the Windows 10 action center using AutoIt. Maybe via rundll or some other applet?
      My intention is to just hide the normal icon, then have an AutoIt system tray icon that will open the action center on click. And I can't just send the Win+A hotkey because I have it disabled. 
      Thanks for reading.
    • TMelanson
      By TMelanson
      Hi folks,
      I'm hoping someone can help me out here.
      Background:
      I have the need to run a program with admin credentials (#RequireAdmin), and then get the SID of the locally logged in account. Not the admin account.
      If you look at the attached script, Line 16 uses the @UserName variable and returns the SID for the admin account I used to launch the app.
      I want to use line 17 which passes the result of the _GetUsername function which is a username using  ($UserName) to the WMIService.
      I'm getting " The requested action with this object has failed.:" error message.
      Any suggestions would be appreciated!
       
      test1.au3
    • onlineth
      By onlineth
      I’m wondering how to add a Windows Hello option to the additional PIN, Fingerprint, and Facial Recognition options? I'd like an interface that could be linked to the Windows Hello authentication system and AutoIt itself.
      I understand that this discussion did not meet the Forum Rules, I apologize about that. I'd like to point out that this post is asking for a way to attach into the Windows Hello service. I'd like to follow the same concept that YubiKey's interact with Windows Hello as seen here: https://www.yubico.com/2016/09/yubikey-works-windows-hello/.