3

The following commands work on my PC:

reg add Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v everyoneincludesanonymous /t REG_DWORD /d 1 /f
reg add Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v restrictnullsessaccess /t REG_DWORD /d 0

However, on some machines it responds with:

ERROR: Invalid key name.
Type "REG ADD /?" for usage.

I'm unsure as to what is different and how I could handle this.

  • 3
    I would try removing the Computer\ part. – HelpingHand Sep 25 '18 at 19:21
  • Ill try this soon ty – Mark Deven Sep 26 '18 at 20:09
  • Forgot to tell you that that worked. Some PCs need \\%computername%\HKEY... – Mark Deven Oct 7 '18 at 21:30
4

According to the help for REG.EXE ADD /? the format of the registry path must start with either a computer name or one of five root key names:

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]

  KeyName  [\\Machine\]FullKey
           Machine  Name of remote machine - omitting defaults to the
                    current machine. Only HKLM and HKU are available on remote
                    machines.
           FullKey  ROOTKEY\SubKey
           ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
           SubKey   The full name of a registry key under the selected ROOTKEY.

If your KeyName value begins with \\ it will be treated as a computer name, otherwise REG.EXE expects one of the ROOTKEY values. Since your command does not begin the path with \\ REG.EXE expects one of the ROOTKEY values. Because Computer is not one of those five values, you get the error:

ERROR: Invalid key name.
Type "REG QUERY /?" for usage.

You can fix your command by either removing the leading Computer\ from the path:

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v everyoneincludesanonymous /t REG_DWORD /d 1 /f

Or by specifying the computer name using the leading slashes:

reg add \\Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v everyoneincludesanonymous /t REG_DWORD /d 1 /f

Note: This assumes your computer name is actually "Computer". If it isn't provide its actual name.

| improve this answer | |
  • I tried this but still I have faced same "ERROR: Invalid key name.". Then I tried "HKCU" instead of "HKEY_CURRENT_USER" then it is worked for me. This is the sample "REG ADD HKCU\Software\SS64 /v Sample /d "some test data"" which is worked for me and I got from following this urtech.ca/2018/08/…. – Vidu Jan 2 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.