zeenmakr Posted April 25, 2020 Posted April 25, 2020 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?
TheXman Posted April 25, 2020 Posted April 25, 2020 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. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
zeenmakr Posted May 6, 2020 Author Posted May 6, 2020 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.
seadoggie01 Posted July 4, 2020 Posted July 4, 2020 (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 July 4, 2020 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 My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
TheXman Posted July 4, 2020 Posted July 4, 2020 (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 July 4, 2020 by TheXman Correction - I get @error = 1 without #RequireAdmin when writing to HKLM CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
seadoggie01 Posted July 4, 2020 Posted July 4, 2020 (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 July 4, 2020 by seadoggie01 TheXman 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Reveal hidden contents My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Skysnake Posted July 5, 2020 Posted July 5, 2020 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?
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