How to one reg add to Internet Settings with hex value via batch file

batch-filehexinternet explorerregistry

I'm writing a batch file to customize internet explorer's internet properties -> security zones via registry. My code currently alters the template policies in
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\TemplatePolicies\LOW" and "../MEDIUM", it then starts inetcpl.cpl, and then the user must manually move the slider to low in the trusted site zone and then medium in the internet zone.

This can be automated by changing the value CurrentLevel in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" and "../3" respectively. My code for some reason writes a zero to the registry entry "CurrentLevel". I need to set "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2\CurrentLevel" to 0x00010000.

Here is the part of my code that is at fault:

echo Moving sliders...
echo.
set qry="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2"
reg add %qry% /v CurrentLevel /t REG_DWORD /d 65536 /f
set qry="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"
reg add %qry% /v CurrentLevel /t REG_DWORD /d 69632 /f

From a hex to decimal converter '65536'='0x00010000' and '69632'='0x00011000'. Why is my code writing a zero to CurrentLevel?

Documentation that may help can be found HERE

THANK YOU!!!

Best Answer

You don't need to convert to decimal.

The command line accepts Hex. See reg add /? for examples.

reg add %qry% /v CurrentLevel /t REG_DWORD /d 00010000 /f

The /d flag requires that you preface the 8 character hex value with 0x. For example: /d 0x00010000.

Related Topic