Guys, how can i add reg values in regedit from Decimal to Hexadecimal automatically? (in bath file)

Kev 21 Reputation points
2022-01-09T17:03:29.69+00:00

So, i have a code

reg add "bla bla bla" /v "bla bla bla" /t REG_DWORD /d "%problem%" /f >nul 2>&1 , btw %problem% is decimal number

so i need "%problem%" to be Hexadecimal value in decimal system, i tried reg add "bla bla bla" /v "bla bla bla" /t REG_DWORD /h "%problem%" /f >nul 2>&1 (instead /d i tried /h)

but its doesnt work, so how can i put my decima-system value in Hexadecimal cell?]

and i know that my knowledge of bat files is flawed...

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,401 Reputation points
    2022-01-09T20:42:40.757+00:00

    btw %problem% is decimal number

    Then just use it as is. If it's a hex value, then it has to start with "0x".

    reg add hkcu\software /v TestValue /d 0xffff /t REG_DWORD /f  
    reg query hkcu\software /v TestValue   
    reg add hkcu\software /v TestValue /d 16 /t REG_DWORD /f   
    reg query hkcu\software /v TestValue   
      
    

    163435-capture.jpg

    set problem=ffff  
    reg add hkcu\software /v TestValue /d 0x%problem% /t REG_DWORD /f  
    reg query hkcu\software /v TestValue   
    set problem=16  
    reg add hkcu\software /v TestValue /d %problem% /t REG_DWORD /f   
    reg query hkcu\software /v TestValue   
      
    

2 additional answers

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2022-01-09T17:46:41.153+00:00
    0 comments No comments

  2. Prrudram-MSFT 28,281 Reputation points Moderator
    2022-01-09T19:35:53.733+00:00

    Hello @Kev ,

    Thank you for reaching out to Microsoft Q&A platform. Happy to answer your question.
    Please refer to the following thread that has detailed discussion on https://stackoverflow.com/questions/1751581/within-a-windows-batch-file-how-do-i-set-an-environment-variable-with-the-hexad/1752032#1752032
    More examples can be found at the following link https://www.dostips.com/DtCodeCmdLib.php#toHex
    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.