Change Registry Value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
armoz
Posts: 8
Joined: 05 Sep 2020, 11:25

Change Registry Value

25 Sep 2020, 03:21

Hello, I wish to change Installation date through a AHK program, here is the line of code that doesn't seem to work..

Code: Select all

RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\Windows NT\CurrentVersion, InstallDate, 1588768950

Key Name - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion


Also, the value I want to input is decimal (not hexadecimal) which will be generated randomly..

It would be great if you can help me to generate a random string that starts with 1, followed by 9 random digits (Best if lower than 1601022188 ie- current unix timestamp, although not necessary)

"1"+ 9 random digits.
Eg: 1569878569

Thank you!!!!
Attachments
Untitled.png
Untitled.png (51.48 KiB) Viewed 1518 times
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Change Registry Value

25 Sep 2020, 03:40

Perhaps a permissions issue. What does ErrorLevel and A_LastError say, after using RegWrite?

To create random numbers, you can use Random - although I don't understand why an installation date would be generated randomly 🤷‍♂️ :think:
armoz
Posts: 8
Joined: 05 Sep 2020, 11:25

Re: Change Registry Value

25 Sep 2020, 03:45

I think the code is somewhat wrong, can u confirm if regedit code is right?

Ps - Its just for a video game :P
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Change Registry Value

25 Sep 2020, 03:53

Looks like RegWrite's deprecated syntax, but should still work, I guess, if you have the permissions to write it (you might have to run the script as admin).

But again, what does msgbox % ErrorLevel " : " A_LastError say ? That should tell you, if there was a problem (and even give a hint which one).
armoz
Posts: 8
Joined: 05 Sep 2020, 11:25

Re: Change Registry Value

26 Sep 2020, 02:09

Last error box says -

1 : 5

What does that mean?
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Change Registry Value

26 Sep 2020, 05:25

armoz wrote:
26 Sep 2020, 02:09
Last error box says -

1 : 5

What does that mean?
Translation: An error occurred : ERROR_ACCESS_DENIED
Probably lacking permissions to write the key. Try to run your script as admin.
armoz
Posts: 8
Joined: 05 Sep 2020, 11:25

Re: Change Registry Value

26 Sep 2020, 14:18

I ran as admin, the error code is 0:0

But the date value is unchanged in regedit :(

Thank you for all your help
User avatar
Jim Dunn
Posts: 478
Joined: 01 Sep 2020, 20:21
Location: NSW

Re: Change Registry Value

26 Sep 2020, 23:54

armoz wrote:
25 Sep 2020, 03:21

Code: Select all

RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\Windows NT\CurrentVersion, InstallDate, 1588768950
Key Name - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
The registry path in your code is wrong (although you do quote the correct one right beneath it)

That value lives at SOFTWARE\Microsoft\Windows NT\CurrentVersion , not at SOFTWARE\Microsoft\Windows\Windows NT\CurrentVersion
At the moment you are just writing a new value, in the wrong key, which nothing will ever look at. ;)

:!: Although I don't honestly recommend anyone here tests that, because messing with registry keys/values like that could have unintended consequences.
Last edited by Jim Dunn on 27 Sep 2020, 04:28, edited 2 times in total.
armoz
Posts: 8
Joined: 05 Sep 2020, 11:25

Re: Change Registry Value

27 Sep 2020, 00:07

Got it yesterday, thanks for replying tho :D!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Mateusz53 and 152 guests