Search code examples
registry

How do I specify editing a DWORD in decimal when writing a .reg file?


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.


Solution

  • 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.