Jump to content

Recommended Posts

Posted

Been exchanging values between multiple scripts via ini file and thought to try out RegWrite()/RegRead() but for some reason it fails, Then tried run as Admin and that does the trick. So now found it annoying with uac popup using #RequireAdmin

thought to even tried RunAs(admin...RegWrite()) with admin user and pass but it also fails to write unless run as  #RequireAdmin.

did i missed something or admin is required with this simple task?

Posted
  On 4/25/2020 at 12:03 PM, zeenmakr said:

did i missed something or admin is required with this simple task?

Expand  

If you are trying to manipulate anything under HKLM, then your process needs to be elevated.  Elevation is not required to manipulate the HKCU hive.

  • 2 weeks later...
Posted

What is elevate process means - admin access? Without any knowledge of particular privileges in different hives, I started out under HKEY_CURRENT_CONFIG. Will give HKCU a go, thanks.

  • 1 month later...
Posted (edited)

So is this true? I can't get my script to write to HKCU, but it will read values just fine. I created the path (Computer\HKEY_CURRENT_USER\Software\Seadoggie01\TakeControl) in case RegWrite wouldn't do that, but it refuses to write anything. RegWrite returns False with no error

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted (edited)
  On 7/4/2020 at 4:20 PM, seadoggie01 said:

So is this true?

Expand  

I just tested it again on both Windows 7 & 10, logged in as an Administrator.  Running the script below, it ran without any errors when writing to the HKCU hive.  When I changed it to write to the HKLM hive, without #RequireAdmin, I get @error = 1 (unable to open requested key).

What is odd about your statement, if I understood it correctly, is that you got back a FALSE return without @error set to a non-zero value.  The help file explicitly states that if it is not successful, it will return False and set @error to a non-zero value.

For the record, the registry key did not exist before running the script.

#include <Constants.au3>

RegWrite("HKCU\Software\AAAAA", "A3Test", "REG_SZ", "This is a test value.")
If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "RegWrite failed with @error =" & @error)

MsgBox($MB_ICONINFORMATION, "INFO", "RegWrite was successful.")

Or

#include <Constants.au3>

If Not RegWrite("HKCU\Software\AAAAA", "A3Test", "REG_SZ", "This is a test value.") Then
    Exit MsgBox($MB_ICONERROR, "ERROR", "RegWrite failed with @error =" & @error)
EndIf

MsgBox($MB_ICONINFORMATION, "INFO", "RegWrite was successful.")

They both give the same results.

Edited by TheXman
Correction - I get @error = 1 without #RequireAdmin when writing to HKLM
Posted (edited)

FML. Apparently, $REG_SZ =/= "REG_SZ" and RegWrite doesn't accept the value from AutoItConstants.au3

I don't know why I thought I needed to use the variable, but I did. Please pardon my brain farts. Need more coffee.

Edit: But thank you for testing that for me! I really appreciate it :)

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted
  On 7/4/2020 at 5:53 PM, TheXman said:

What is odd about your statement, if I understood it correctly, is that you got back a FALSE return without @error set to a non-zero value.  The help file explicitly states that if it is not successful, it will return False and set @error to a non-zero value.

Expand  

@TheXman I can confirm that I have also experienced similar silent fails. Windows 10.  :)

 

Skysnake

Why is the snake in the sky?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...