Registry Tricks

Here are some pretty cool ways to work with the Windows registry.

Regedit

Multiple Instances

Start multiple instances of Regedit by appending the command-line parameter -m, e.g.: regedit -m.

Multiple instances of Regedit

Exporting/Importing Favorites

Regedit’s favorites are a handy way to get to keys you often need. The list of favorites is stored in the registry (where else?): HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites. Exporting the favorites to a .REG file can easily be automated with reg.exe (see below).

REG Files

Exporting to REG Files

While there is no API function to create .REG files, Windows includes the tool reg.exe that is more than up to this task. Here is an example command that exports the “User Shell Folders” key including all subkeys and values to the file ShellFolders.reg:

reg export "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" ShellFolders.reg

To export Regedit’s favorites to Regedit-Favorites.reg:

reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\Favorites" Regedit-Favorites.reg

Deleting Keys and Values Through REG Files

Adding keys and values to the registry with .reg files is obvious. But deleting is possible, too. Please note the use of the hyphens (-).

These lines delete the value testval1:

[HKEY_CURRENT_USER\Software\Test]
"testval1"=-

This line deletes the entire key “Test” including all subkeys and values:

[-HKEY_CURRENT_USER\Software\Test]

Commenting REG Files

.REG files can be commented, similar to .INI files. Comments are marked with a semicolon, as shown in the following example:

; This is a comment explaining why testval1 should be deleted
[HKEY_CURRENT_USER\Software\Test]
"testval1"=-

Registry Timestamps

Each registry key has a timestamp that stores the last modification time just like a folder in the file system. That information can come in handy at times, but it is not too easy to retrieve. Here are some ways to get to the timestamp:

Export to text in regedit:

Export the key in Regedit, selecting .TXT as file type. The resulting text file contains the last write access date and time:

Regedit export to text

Use Registry Commander

There are several things the free tool Registry Commander can do that Regedit cannot, displaying key timestamps is one of them:

Registry Commander

Query the Windows API

You are a programmer and need registry key timestamps in your application? Do what Regedit and Registry Commander do: use the Windows API function RegQueryInfoKey.

And .NET? Sorry, nothing there. The .NET framework is an abstraction of the “real” C++ APIs and as such hides ugly details but also gems like a registry key’s timestamp.

Reg.exe on Windows x64

The swiss army knife of registry tools, reg.exe, has a little-known switch to make it access the 64-bit or 32-bit views of the registry explicitly. For example, to get to the 64-bit view of HKLM\Software from a 32-bit process use:

reg query hklm\software /reg:64

The variant /reg:32 works, too. Use that to see the 32-bit view from a 64-bit process.

Note: This switch requires hotfix KB948698 to be installed on older operating systems. Windows 7 and Server 2008 R2 include the fix.

Comments

Related Posts

Registry Fun (Working With Hive Files)

Sometimes it is necessary to export/import data from or into the registry for some sort of additional processing. To this end, often regedit is used to create .REG files, which store a human-readable text interpretation of the registry content. .REG files can be edited easily with any capable text editor (even Notepad), and thus are a common way of making a collection of settings available to others. By the way, importing a .REG file’s data silently is done with the following command:
Windows Internals

Hardware-Encode Video in H.265 with Free Tools to Save Disk Space

Hardware-Encode Video in H.265 with Free Tools to Save Disk Space
Many web meeting services have a recording functionality. Most recordings are provided as MP4 files with the video encoded in H.264 because that offers the most universal compatibility. However, it also needs a lot of disk space. H.264 has a successor, H.265, which only requires half the space for the same visual quality. This post shows how to use StaxRip, a free tool, to re-encode H.264 video into H.265 quickly by making use of GPU hardware encoding.
Tips and Tools

Latest Posts