DoktorSanchez Posted August 16, 2012 Posted August 16, 2012 Hi, So i've been using autoit at work for automation of installs - picking things up as I go. Ive had a look for an answer on the forums but so far havet found what I was after. Currently im making a script that will restart the window update service on some of our clients machines. I have the command i need to run, which disables the service; reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' /v AUOptions /t REG_DWORD /d 1 /f However I cant seem to get it to run using autoit. I have; RunWait(@ComSpec & "/c reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' /v AUOptions /t REG_DWORD /d 1 /f","", @SW_HIDE) Could anyone shed some light on what I might be overlooking? Much appreciated
JohnQSmith Posted August 16, 2012 Posted August 16, 2012 Why not just do it directly with AutoIt using RegWrite()? Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".
lordofthestrings Posted August 17, 2012 Posted August 17, 2012 if you really want to do it like this, you forgot the space between @comspec & " " & "/C"
DoktorSanchez Posted August 17, 2012 Author Posted August 17, 2012 Regwrite.. thats a much better idea! So I have changed the code to this; RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto Update", "AUOptions", "REG_DWORD", "1") However when I check the registry in regedit, it doesnt seem to have changed the value, in this case from '4' (allow automatic updates) to '1' (disabled) Im able to create new reg keys - do i need to delete the existing one before writing a new one?
DoktorSanchez Posted August 17, 2012 Author Posted August 17, 2012 So it looks like I am able to edit HKEY_CURRENT_USER values and keys after testing, but not HKEY_LOCAL_MACHINE values or keys. Is this likely a permissions issue?
KaFu Posted August 17, 2012 Posted August 17, 2012 If you'r running Vista+, then yes. Take a look at the help-file section "AutoIt on Windows Vista". To write to HKEY_LOCAL_MACHINE you have to run the script as admin, either add #requireadmin or #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator to your script. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
DoktorSanchez Posted August 17, 2012 Author Posted August 17, 2012 Thanks for the heads up KaFu - I have tried with both, and still cant seem to write to HKEY_LOCAL_MACHINE. When I add #requireadmin I do get a UAC prompt, but still no changes are made in the registry. Apologies for the noobishness - its early days! Will keep plugging away. Incidentally cant seem to find this help file section...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now