is-hklm-an-alias-for-hkey-local-machine-00

Sometimes when working with Windows, you see all manner of names, abbreviations, and identifiers such as HKLM and HKEY_LOCAL_MACHINE for example. Is HKLM simply an alias for HKEY_LOCAL_MACHINE or are there ‘differences’ between the two? Today’s SuperUser Q&A post has the answers to a curious reader’s question.

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

Screenshot courtesy of wandersick (Flickr).

The Question

SuperUser reader Joe Kearney wants to know if HKLM is just an alias for HKEY_LOCAL_MACHINE or if there really are differences between the two at times:

HKLM is often used as an abbreviation for HKEY_LOCAL_MACHINE, but unexpectedly, this also appears to be true when I ask the Reg. for a value.

  • C:\>reg query “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion” /v “CurrentVersion”
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    CurrentVersion    REG_SZ    6.1
  • C:\>reg query “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion” /v “CurrentVersion”
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    CurrentVersion    REG_SZ    6.1

Are there any references asserting that they are equivalent or that one is an alias for the other? Or are there, in fact, cases where they are not the same thing?

Is HKLM simply an alias for HKEY_LOCAL_MACHINE or are there actually some differences between the two?

The Answer

SuperUser contributors Twinkles and john smith have the answer for us. First up, Twinkles:

No, although HKLM is an abbreviation for HKEY_LOCAL_MACHINE, there is no official statement from Microsoft that it is always equivalent. In fact, it explicitly states that the availability of these shortcuts depend on the software being used and they are generally referred to as commonly used abbreviations.

There are cases where abbreviating HKEY_LOCAL_MACHINE to HKLM is not permitted, for instance when defining a policy.

Followed by the answer from john smith:

You also cannot use these abbreviations in .reg files, you have to write the full name inside the square scopes there.


Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.