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

    • dreivilo47
      By dreivilo47
      When I want to test Example 1 of Function _IECreate (AutoIt Help File), I see that function _IECreate doesn't work in Windows 10.
      Syntax Check (Ctrl+F5) gives no errors.
       
      Example 1:
      ; Create a browser window and navigate to a website #include <IE.au3> Local $oIE = _IECreate("www.autoitscript.com")  
      The error I receive with F5 (Tools, Go) in SciTE:

    • Chaym
      By Chaym
      Does AutoIT supported  in Windows 10 OS (x64)?
      After installing AutoIT in x64 OS and recompiling code,
      I get a lot of error messages...
       
    • kristo
      By kristo
      The DriveGetDrive command returned all drives (option "ALL") for years now and my program could always rely on that function. Suddenly a drive letter that was created with the subst command does not appear in the list of drives anymore. And it clearly did, because I used to react to a certain subst command by reacting to new or revoked (subst /D) drive letters.
      Why is that? I think this a bug because there's no way left to list ALL drive letters anymore.
      And why should I use an API command for that when this was already built in for years?

       
    • kokoilie
      By kokoilie
      I'm making a program that has a combo control in a gui and back in win7 when the window was focused the scroll wheel could be used to scroll through it's contents, now i'm using win10 and i have to put the mouse on that control to scroll up and down.
      Since now the scroll wheel works depending on where the mouse is, is there a way to make it no matter where on the gui the pointer is?
      Also if the only way to do it is some complex hotkey functions will it work with pressing space to toggle a checkbox?
      If you need to see what i have so far let me know and i'll copy it here.
    • ModemJunki
      By ModemJunki
      Hello,
      In Windows 10 PowerShell, one can do this to change the metric for a NIC in Windows 10:
      Get-NetAdapter | Where-Object -FilterScript {$_.InterfaceAlias -Eq "Ethernet 2"} | Set-NetIPInterface -InterfaceMetric 2 I know I can script the above PowerShell line (and it works!), but I wanted to try something I hadn't done before after looking into jguinch's most excellent Network configuration UDF. I wanted to make use of the SetIPConnectionMetric method in the WMI classes. There is an example VBscript here but this is not for Windows 10. Using AutoIT would also give better control over capturing error return codes than with PowerShell.
      But I cannot get my script to work! The return from SetIPConnectionMetric() is 0, which would indicate success. Yet the change does not happen. I also tried WMI methods using .put_ but this fails.
      Anyone more experienced than I have ideas to make this work?
      #RequireAdmin _SetNicInterfaceMetric2("Ethernet 2", "2") Func _SetNicInterfaceMetric2($NIC_NAME, $METRIC) Local $s_setIndx = 0 $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") $colNICItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = '" & $NIC_NAME & "'", "WQL") If IsObj($colNICItems) Then For $objItem In $colNICItems $s_nicIndex = $objItem.Index Next ConsoleWrite("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'" & @CRLF) $colNAC = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'", "WQL") If IsObj($colNAC) Then For $objNetCard In $colNAC If $METRIC <> $objNetCard.IPConnectionMetric Then ConsoleWrite("Metric was set to " & $objNetCard.IPConnectionMetric & ". Setting to " & $METRIC & "." & @CRLF) $s_isSet = $objNetCard.SetIPConnectionMetric($METRIC) ConsoleWrite("SetIPConnectionMetric Result = " & $s_isSet & @CRLF) Else ConsoleWrite("Metric is already set to " & $METRIC & @CRLF) EndIf Next EndIf EndIf EndFunc ;==>_SetNicInterfaceMetric2