Hello,
When you write registry key it will not work in HKEY_LOCAL_MACHINE:
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE\SOFTWARE\TestKey, MyValueName, Test Value
When you write registry it works fine in HKEY_CURRENT_USER:
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\TestKey, MyValueName, Test Value
So the bug is in HKEY_LOCAL_MACHINE.
By the way you don't need any admin rights to write this key in HKEY_LOCAL_MACHINE if you do it manually.
This issue exist in AHK version 1.1.30.01.
Bug in Regwrite in HKEY_LOCAL_MACHINE
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
Interesting, on my Win 10 system I need them.By the way you don't need any admin rights to write this key in HKEY_LOCAL_MACHINE if you do it manually.
What do they tell you?ErrorLevel
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
ErrorLevel is set to 1 if there was a problem or 0 otherwise.
A_LastError is set to the result of the operating system's GetLastError() function.
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
The values are:
ErrorLevel = 1
A_LastError = 5
ErrorLevel = 1
A_LastError = 5
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
What is causing this error if it is not in admin rights?
-
- Posts: 33
- Joined: 07 Sep 2018, 15:54
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
Edit: About a minute after hitting submit I stumbled across this (On a totally different MSDN page in my defense):
However, I'm not sure why RegEdit would let you while RegWrite fails.
The rest of this post is incorrect, so you can just ignore it.
So the problem is that your account doesn't have permission to create the key, which matches what you got for ErrorLevel and LastError.When you call the RegOpenKeyEx function, the system checks the requested access rights... If the user does not have the correct access to the registry key, the open operation fails.
However, I'm not sure why RegEdit would let you while RegWrite fails.
The rest of this post is incorrect, so you can just ignore it.
Spoiler
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
I'm on v1.1.30.01 currently, any news on when this is going to get fixed? I have the same issue, I can't write to HKLM.
This is my thread: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=67974&p=292326#p292326
This is my thread: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=67974&p=292326#p292326
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
wiens wrote: The values are:
ErrorLevel = 1
A_LastError = 5
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
never heard of writing to HKLM not requiring admin access. ur regedit must have been running elevated
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
@just me Nice I just saw your post here, so it means we're on the same boat, I understand that I'm getting Access denied (Error 5) but I am running my script as Administrator, I don't know what I'm missing?
Last edited by XShayanX on 14 Sep 2019, 13:20, edited 1 time in total.
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
try it from your same shk script with Run, %comspec% reg add hklm/...
Then you will make sure both methods are using the same elevation coming from the same process... My guess is they will act the same, I’ll try on my machine later
Then you will make sure both methods are using the same elevation coming from the same process... My guess is they will act the same, I’ll try on my machine later
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
gwarble, it didn't work with that workaround for me.
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
that means its an elevation/permission issue as was first recommended
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Re: Bug in Regwrite in HKEY_LOCAL_MACHINE
I doubt there's a bug here.
What does MsgBox % A_IsAdmin say?
What permissions does your account have to this registry key? You can check by right clicking on the key in regedit and selecting Permissions....
With UAC set to "Notify me only when applications try to make changes to my computer (default)", it will not notify you when you launch certain system applications, such as regedit, even though they are elevated to admin. Some system applications will only run with limited permissions if the current user is not a member of the Administrators group, while others will not run at all in that situation, or will require you to enter an admin username and password.
What does MsgBox % A_IsAdmin say?
What permissions does your account have to this registry key? You can check by right clicking on the key in regedit and selecting Permissions....
With UAC set to "Notify me only when applications try to make changes to my computer (default)", it will not notify you when you launch certain system applications, such as regedit, even though they are elevated to admin. Some system applications will only run with limited permissions if the current user is not a member of the Administrators group, while others will not run at all in that situation, or will require you to enter an admin username and password.
Who is online
Users browsing this forum: Billykid, dinodragon, mcd and 146 guests