Reputation: 300
I'm making a little batch program that edits screensavers by making a reg file and opening it. However, I need the .reg
file to known that these values will be in decimal, not the default hex. Is there anyway to do this?
BTW.
The answer has to use the .reg
format, not batch; therfore the answer must not contain batch.
Upvotes: 4
Views: 15112
Reputation: 10708
The other answers are correct in that there is no way to specify a DWORD value in decimal, only in hex.
To set a DWORD in a .reg file, use this syntax:
Windows Registry Editor Version 5.00
[Full\Path\To\Key]
"KeyName"=dword:abc123
Note that the value after dword:
is always interpreted as hex even though it does not (and can not) have the common hex prefix "0x".
Upvotes: 3
Reputation: 56
You could try converting your decimal entry into hexadecimal and put that in the registry using reg add
. Use something like this:
set decentry=%YOUR DECIMAL ENTRY%
call cmd /c exit /b %decentry%
set hexentry=%exitcode%
reg add ROOTKEY\Subkey /v VALUENAME /t REG_DWORD /d %hexentry% /f
What this program does, it takes the string %YOUR DECIMAL ENTRY%
that you provide and converts it from your decimal format to hex. Then it overwrites the previous registry entry with the hex.
I hope this is what you were looking for. I didn't quite understand what you meant by wanting the answer in .reg format.
Upvotes: 1
Reputation: 4677
Not what you want to hear, but if you are using a .REG file, you must/can only specify the values for REG_DWORD in hex.
You can set the value in decimal using the REG ADD command, but that is clearly not what you wanted to do.
Upvotes: 9