Search code examples
batch-filecommand-linecmdregistry

Add registry from bat file


I am trying to add registry entry from bat file. I have a reg file that contains

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001

It works if you double click the reg file. However, I need to make the same registry edit from bat file. I have tried this

reg add HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel /v HomePage /t REG_DWORD /d 0 /f

But doesnt work. What is the correct way to do that ? (except running .reg file from bat file)


Solution

  • Put quotes around the key name.

    reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /v HomePage /t REG_DWORD /d 0 /f
    

    Because "Internet Explorer" and "Control Panel" contain spaces, you need quotes so it is all treated as one parameter.