Jump to content

RegWrite - HKLM - W10


 Share

Go to solution Solved by Jos,

Recommended Posts

Hello,

I am trying to use RegWrite to create a key within HKLM on W10 without success.

I've had a look at a number of posts on the forum to troubleshoot, without success.

This post seems highly relevant

Here is my latest script with output

; Read/write data to registry

#RequireAdmin

Example()

Func Example()

    Local $Status = ""

    ; Check if the registry key is already existing, so as not to damage the user's system.
    RegRead("HKLM\SOFTWARE\Microsoft\F1", "Key1")
    ConsoleWrite("Error: " & @error & @CRLF)

    ; Write a single REG_SZ value to the key "Key1".
    $Status = RegWrite("HKLM\SOFTWARE\Microsoft\F1", "Key1", "REG_SZ", "This is an example of RegWrite")
    ConsoleWrite("Status: " & $Status & @TAB & " Error: " & @error & @CRLF)

EndFunc   ;==>Example

 

Output

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "D:\Temp\Macrium\Registry_write_read.au3" /UserParams    
+>16:18:46 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\ZEN\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\ZEN\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.16.1)  from:C:\Program Files (x86)\AutoIt3  input:D:\Temp\Registry_write_read.au3
+>16:18:47 AU3Check ended.rc:0
>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\Temp\Registry_write_read.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
Error: 0
Status: 1    Error: 0
+>16:18:47 AutoIt3.exe ended.rc:0
+>16:18:48 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.362

 

The user is a local admin.

According to the script output, the regwrite call should have succeeded.

SciTe has been runas admin.

I've also tried compiling the script and running the resulting exe as admin.

Obviously I can't see the consolewrite output when I do this, but if the function calls were working then the exe should update the registry.

After suggestions as to options to try next.

Also, I tried narrowing down the forum search using arguments like: "regwrite windows 10" or "regwrite windows10" and for some reason had no results on the search; so had to use more general search arguments. Would be interested to know why the above wouldn't work as a search argument.

Thanks

VW

Link to comment
Share on other sites

@Jos

Unfortunately the registry entry is not being updated.

I agree that everything looks right. Which makes it hard to troubleshoot. 

I could kind of understand if the script didn't work, but an exe runas admin did. And while that would be a little inconvenient, I could work with that.

FWIW the original example script which updates HKCU I think, one of the user hives anyway, that does work.

But for what I am wanting to do it makes more sense to use HKLM rather than a user hive.

Link to comment
Share on other sites

  • Developers
  • Solution

Where are you look in the registry to check for the update?  

in Computer\HKEY_LOCAL_MACHINE\SOFTWARE  or Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node?

Edited by Jos

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

2 hours ago, Jos said:

Where are you look in the registry to check for the update?  

in Computer\HKEY_LOCAL_MACHINE\SOFTWARE  or Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node?

I was looking in the first entry.

Thanks!

Link to comment
Share on other sites

  • Developers

That's what I suspected as you are running the script with the 32bits version of AutoIt3. :) 

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

When using 32bit compiled script just use HKLM64

HKLM64 will write to HKEY_LOCAL_MACHINE

HKLM will write to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432

#RequireAdmin

Example()

Func Example()

    Local $Status = ""

    ; Check if the registry key is already existing, so as not to damage the user's system.
    RegRead("HKLM64\SOFTWARE\Microsoft\F1", "Key1")
    ConsoleWrite("Error: " & @error & @CRLF)

    ; Write a single REG_SZ value to the key "Key1".
    $Status = RegWrite("HKLM64\SOFTWARE\Microsoft\F1", "Key1", "REG_SZ", "This is an example of RegWrite")
    ConsoleWrite("Status: " & $Status & @TAB & " Error: " & @error & @CRLF)

EndFunc   ;==>Example

 

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