Changing the default value of a regkey

Having issues with changing the default value of a registry key. The key is HKEY_CLASSES_ROOT\.bat

Seems that no matter how I try to do this, the local log shows success, but the key is never changed. Sure I’m overlooking something simple. Here are a few of the things I have tried.

[waithidden REG Add "HKEY_CLASSES_ROOT\.bat" /ve /d "batfile" /f

regset "[HKEY_CLASSES_ROOT\.bat]" ""="batfile"

Also tried a .reg file with  

[-HKEY_CLASSES_ROOT\.bat]

[HKEY_CLASSES_ROOT\.bat]
@="batfile"

with various (unnecessary?) combinations of x64 and other settings. I can set the key on any machine using both reg files and the above reg command. Beating my head against the wall on this one. Any help would be appreciated.

Lot of complications on what you’re trying to do, I’ll try to take them one at a time…

The “waithidden” command should not have a [ symbol in front of it. You may need to disable 32-bit redirection. And… HKEY_CLASSES_ROOT is a virtual hive (more on that below).

The empty string "" is not the name of the default value - it’s name is referred to as "@", in both a .reg file and the ‘regset’ ActionScript command. Also may be subject to 33-bit redirection, so ‘regset64’ instead. I still don’t think this will work (again virtual hive, more below), but it would be the right format to set a default value on other keys

regset64 "[HKEY_CLASSES_ROOT\.bat]" "@"="batfile"

I expect the two .reg files would work (with ‘action uses wow64 redirection false’) for other keys, but not for HKCR.

HKEY_CLASSES_ROOT is a virtual hive - a view made from combining HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes. When you try to import into HKCR directly, it goes into the per-user view - in this case the HKEY_CURRENT_USER of the LocalSystem account, where you won’t see it under your own account. Instead, build your commands to update the source key at HKLM\Software\Classes and it should give the effect you want (and check you don’t have your own copy in HKCU overriding it). So try

regset64 "[HKEY_LOCAL_MACHINE\Software\Classes\.bat]" "@"="batfile"
3 Likes

Yes. Thank you for pointing me in the right direction! I was able to resolve this by setting the HKLM key using your command and deleting the HKCU key.

1 Like