damon

RegWrite with Windows 10

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


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

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

    • Traskiz
      Windows 10 RunAs script problem
      By Traskiz
      Hello,
       
      I have a problem, I cant run script as administrator in Windows 10:
      main.exe:
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'EnableBITSMaxBandwidth','REG_DWORD',Number('1'))
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'MaxTransferRateOnSchedule','REG_DWORD',Number('100'))
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'MaxBandwidthValidFrom','REG_DWORD',Number('7'))
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'MaxBandwidthValidTo','REG_DWORD',Number('22'))
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'UseSystemMaximum','REG_DWORD',Number('1'))
      RegWrite('HKLM\SOFTWARE\Policies\Microsoft\Windows\BITS', 'MaxTransferRateOffSchedule','REG_DWORD',Number('400'))
      run.exe:
      Global $sUserName = "administrator"
      Global $sPassword = "pass"
      Global $sDomain = "domain"
      RunAsWait($sUserName, $sDomain, $sPassword, 2, "main.exe", "", @TempDir)
      If I run "run.exe" it dont work...
      If  I change main.exe to this:
      msgbox(1,"",@username)        
      and it runs and shows administrator in message box... but it cant elevate main.exe with RegWrite() command...
       
      I tried using #RequireAdmin in first line of main.exe, but it not worked... UAC is set to "do not notify"
       
       
      This method of elevation worked on Windows 7 and Windows XP...
      Please help!
    • dreivilo47
      [Solved] WinMenuSelectItem doesn't work with my Dutch Notepad
      By dreivilo47
      I have a Dutch version of Windows 10.
      The Dutch word for "File" = "Bestand" and for "Page Setup" = "Pagina-instelling".
      WinMenuSelectItem doesn't select this items.  What can be the reason?
       
      Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") WinMenuSelectItem("[CLASS:Notepad]", "", "Bestand", "Pagina-instelling...") Sleep(4000) WinClose("[CLASS:Notepad]")  
    • dreivilo47
      [SOLVED] How to solve this problem?
      By dreivilo47
      When I use the following code I receive an UAC message:
       
      #RequireAdmin RunWait("msiexec /i winzip205-64.msi /quiet") Exit How can I hide (bypass) the UAC message?
    • scintilla4evr
      _WinAPI_DwmEnableBlurBehindWindow for Windows 10
      By scintilla4evr
      Function for enabling Aero-like blur effect in Windows 10.
    • scintilla4evr
      _WinAPI_DwmEnableBlurBehindWindow in Windows 10
      By scintilla4evr
      Hello! As some of you probably know, _WinAPI_DwmEnableBlurBehindWindow does not work as you'd like it to work in Windows 10. It doesn't add Aero-like blur, as seen in the new Start menu or Notification Center. I looked for a solution and found "the most elegant" one:

      The blur only affects the inside of the window and it is not colored. It can be enabled via an undocumented SetWindowCompositionAttribute function in user32.dll.
      _WinAPI_DwmEnableBlurBehindWindow for Windows 10 - this archive contains both the UDF and the example.