Thursday, July 19, 2012

Accessing the Registry by String

PowerShell has its own shortcut syntax for accessing the registry HKEYs, like hkcu:.  It is part of the system of providers and psDrives.  But other programs deal with the whole HKEY name, like hkey_current_user.

I just learned that in a registry path string "hkcu:\" is equivalent to "registry::hkey_current_user\".  So if you have a long path for a registry, just tack on that "registry::", and you'll be fine.  This is also necessary for any registry HKEYs that don't have abbreviations, as HKCU and HKLM do (unless you make your own PSDrive).  

No comments:

Post a Comment