1
votes

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!!!

1
and please… when you paste code here in the editor here, use the toolbar to format it, do not put <br>s… - Benoit
Sorry, I am new. I will use the toolbar from now on. Thanks for the tip. - pointgod36
do you run your batch having sufficient rights for modifying HKLM ? - Benoit
Yes, I am running it on XP as administrator - pointgod36
@pointgod36 I copied/pasted your code and successfully ran it on my XP machine. Do you get any messages? - aphoria

1 Answers

2
votes

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.