Windows Registry Tutorial
Windows Registry Tutorial
Windows Registry Tutorial
Tutorial
1
Table of Contents
Introduction
Final Word 18
Useful References 19
About Netwrix 21
2
Introduction
You can change registry key values manually using the built-in Windows Registry Editor
(regedit) in order to improve performance or make Windows work the way you want,
but you need to know what you’re doing or you can seriously damage your OS. Your
registry can also be changed by malware or due to errors during the installation of
programs or drivers. Unwanted changes are likely to cause issues with your Windows
registry and therefore negatively affect the performance of your computer or even
damage it. You can remediate these problems by fixing Windows registry issues or
restoring your registry from a backup.
This tutorial covers all you need to know to effectively manage the Windows registry,
including how to perform basic management tasks, fix registry issues, and back up
and restore your Windows registry.
Introduction 3
I. Performing Basic Registry
Management
Administrators can perform all typical registry operations using either the “Regedit”
user interface or the reg.exe utility. But there is another option — Windows
PowerShell. PowerShell provides a large set of tools for interacting with the Microsoft
Windows registry, either on the local machine or remotely.
In this chapter, we'll show how to use PowerShell to get, edit, create and delete registry
keys; search the registry; and connect to the registry from a remote computer.
get-psdrive
Figure 1.1
Getting a list of the local drives
As you can see, there are two entries for the registry: HKEY_CURRENT_USER (HKCU)
and HKEY_LOCAL_MACHINE (HKLM). These are two logical groups of keys, or “hives,”
in the registry.
cd HKLM:\
Alternatively, we can set our current working location to a particular path in the
registry using the Set-Location cmdlet:
Then we can use the Get-ChildItem cmdlet to output all the registry keys in the current
hive with their properties:
Get-childitem
Figure 1.2
Getting a list of the registry keys
with their properties
To get the parameters for a specific key (such as the Run key), we would use Get-Item
cmdlet, specifying the path:
If we want to change one of the parameters for a registry key, we need to use the
Set-ItemProperty cmdlet. For example, we could use the following command to set
a new string value for the “VMware User Process” parameter of the “Run” key:
PowerShell enables you to connect to a computer’s registry remotely and view it using
Remotely WinRM. To do that, you need to use the Invoke-Command cmdlet:
The system will prompt you for the password for the user account you specified. After
authentication, you will be able to use PowerShell commands on the remote computer.
Figure 1.4
Creating a new registry key
And now let’s create a parameter called “NetwrixParam” for our new key and set its
value to the string “NetwrixValue”:
Figure 1.5
Creating a parameter for a new
registry key
The –Recurse parameter authorizes PowerShell to delete all the subkeys without addi-
tional confirmation (of course, we didn’t create any subkeys in this example).
If you want to delete all subkeys inside the specified key without deleting the key itself,
you should add the “*” symbol at the end of the path:
As the previous chapter illustrates, basic registry management tasks are rather easy.
However, when you’ve been running the Windows OS for some time — installing and
uninstalling programs, swapping in different keyboard and mice, and so on — you end
up with hundreds or even thousands of registry entries that are completely useless.
Each one uses very little hard drive space, but the operating system still has to filter
through all of them each time it refers to the registry, which slows down performance.
By cleaning up the registry, you can get rid of those unwanted entries and make your
system run a little bit faster. Moreover, sometimes it is necessary to fix registry errors,
or repair the registry if a simple fix doesn’t work. For example, malware can mess up
the registry to the point that a repair operation is required.
In this chapter, we will discuss how to clean your Windows registry, fix errors and
repair the registry if necessary.
3. Locate any applications that have already been uninstalled and delete them:
a. Expand the HKEY_CURRENT_USER section and then expand the Software key.
b. Look for keys for based on the name of the uninstalled applications or the ven-
dor and delete them.
4. Next, find and remove any duplicate keys that the uninstalled application might
have left behind:
b. Enter the name of the uninstalled application and click OK to search. Each
matching key or value will be highlighted.
d. Press F3 to find the next match and delete it. Repeat this step until you have re-
viewed all highlighted items.
b. Click Run to list shortcuts to all the executable files that run at startup.
c. Delete any applications that you don’t want to run at Windows startup. Do
an online search to investigate any that are unfamiliar.
d. Repeat the same task for the following key paths as well:
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\ CurrentVersion\Run
Orphaned entries. Orphaned entries occur when you uninstall software and small
fragments of registry entries are left behind. Registry cleaner software will often
claim these are an immediate issue, but in reality, they will just use up a few kilo-
bytes of free space on your disk.
Duplicate keys. Duplicate keys are made when you reinstall, upgrade or update
software on your machine, including the operating system. Registry cleaner soft-
ware will state that your programs will be confused by the duplicate entries, slow-
ing your machines performance, but that is not true.
Fragmented registry. The registry can also fragment when software is uninstalled,
upgraded or updated.
System shutdown errors. Each time your computer shuts down, a copy of the
registry is saved to system memory. If your computer is turned off, crashes or dies
without going through the normal shutdown routine, it could cause an issue in the
future, but this is unlikely.
If a recent change to your system caused errors in your registry, you can revert your
Fixing Windows computer's registry settings using a Windows restore point. If your computer has
Registry Errors with System Restore enabled, restore points will be created automatically when major
changes are made to the system, such as the installation of new drivers. You can also
System Restore
create restore points manually.
1. To open the System Restore window, click the Start menu and enter "restore" in the
search box.
3. Select a restore point. Windows will select the most recent restore point. If the er-
ror has been around for a while, click Show more restore points to see previous
ones. Each restore point will have a timestamp as well as a brief description of why
the restore point was created.
4. Click Scan for affected programs to see all of the programs and drivers that will be
deleted from the computer and all programs that will likely not work correctly if you
proceed with the restore. A system restore will not affect any of your personal files.
5. Click Next and then Finish to start the restore process. This may take a few minutes.
Your computer will reboot after the restore is complete.
Another way to fix a corrupted registry is to run the System File Checker:
Fixing Broken Registry
Items with System 1. Run cmd.exe with administrator rights.
File Checker
2. In the command window, type “sfc /scannow” and press Enter.
Windows 10 allows you to reset your computer and leave all your files untouched. This
Refreshing option completely refreshes your system files and may help you fix registry issues.
the Windows System Here are the steps to follow:
2. Select Recovery.
3. In the Reset This PC section, click Get Started and then click Keep My Files.
Newer versions of Microsoft Windows include an automatic repair feature. When you
Repairing the Registry run Automatic Repair, it will attempt to fix corrupt registry keys and repair invalid keys.
with Automatic Repair Take these steps:
7. Automatic repair will start and your computer may reboot during this process.
To repair the registry with the DISM command follow these steps:
Repairing the Registry
with the DISM 1. Run cmd.exe with administrator rights.
Command
2. Run the following command: DISM /Online /Cleanup-Image /ScanHealth
If these methods didn’t fix your registry problems, then you probably will have to re-
install Windows from scratch.
You should back up your registry on a regular schedule and before any major change
so you can restore it if the installation of a program or driver causes issues. The cor-
ruption of a registry file during the installation process can lead to poor performance
or even the operating system crashing. With a backup of the registry, you can always
revert unwanted changes and restore the performance of your operating system.
In this chapter, we will see how to make a backup of your Windows registry and
several methods for restoring it.
1. Press the Windows button and the R button simultaneously to open the Run
window.
4. In the dialogue box, enter a name for the backup file (for example “rgbkp2018”),
select the location where you want to export registry file and click Save to create
and save the backup.
Figure 3.1
Backing up a Windows registry
This is the most basic method. First, boot Windows in Safe Mode by pressing the F8
Restoring the button while turning your computer on. When you boot in Safe Mode, Windows loads
Registry Backup a minimal environment that helps ensure a stable system and protect vital files and
drivers from corruption. Once you’ve booted into Safe Mode, perform the following
from Safe Mode commands:
1. Press the Windows button and the R button simultaneously to open the Run
window.
4. In the Import Registry dialogue box, browse to the location where you saved the
file of your backup and click Open.
Figure 3.2
Restoring a Windows registry
from a backup file
Alternatively, a slightly quicker method is to browse to the location with the backup,
right-click the file and select Merge. The file will be automatically imported to your
registry.
We’ll be assuming your Windows directory is located on the C drive. Enter these com-
mands to change your working directory to the directory with your backup:
Cd /d C:\windows\System32\config
xcopy *.* C:\RegBack\
cd RegBack
dir
Then replace the current registry settings with the ones from the backup using these
commands:
copy /y software ..
copy /y system ..
copy /y sam ..
You can also restore your computer's registry using a Windows system restore point.
Restoring If your computer has System Restore enabled, restore points will be created automa-
the Windows Registry tically when major changes are made to the system, such as the installation of new
drivers. You can also create restore points manually.
with System Restore
1. To open the System Restore window, click the Start menu and enter "restore" in the
search box.
3. Select a restore point. Windows will select the most recent restore point. If the
registry corruption has been around for a while, click Show more restore points to
see earlier ones. Each restore point will have a timestamp as well as a brief descrip-
tion of why the restore point was created.
5. Click Next and then Finish to start the restore process. This may take a few min-
utes. Your computer will reboot after the restore is complete.
Newer versions of Microsoft Windows, starting from Windows XP, include an auto-
Restoring the Registry matic repair feature. When you run Automatic Repair, it will attempt to fix corrupt
with Automatic Repair registry keys and repair invalid keys. In Windows 10, take these steps (note that in
Windows XP, Windows Vista and Windows 7, the steps might be different):
4. After the computer reboots, on the Choose an option screen, click Troubleshoot.
7. Automatic repair will start. Your computer might reboot during this process.
Another way to fix a corrupted registry is to run the System File Checker:
Restoring
the Registry with 1. Run cmd.exe with administrator rights.
System File Checker
2. In the command window, type “sfc /scannow” and press Enter.
Windows 10 allows you to reset your computer and leave all your files untouched. This
Restoring the Registry option completely refreshes your system files and may help with restoring the registry
by Resetting the PC after a system crash. Here are the steps to follow:
2. Select Recovery.
3. In the Reset This PC section, click Get Started and then click Keep My Files.
If these methods didn’t fix your registry problems, then you probably will have to re-
Reinstalling Windows install Windows from scratch, which will reset the registry to factory settings.
In this tutorial you’ve learned how to manage your registry using PowerShell and other
tools. However, keep in mind that even one incorrect change to the registry can lead
your operating system to the blue screen of death. Therefore, before you make any
changes to your registry, be 100% sure of what you are changing, have current back-
ups of your system and data, and track all the changes you make.
In fact, routinely tracking changes to your registry is a smart strategy. For example,
one of the first steps malware often takes is to change registry startup keys. If you spot
those changes quickly, you can take steps to block the malicious software before it
does real damage to your systems and data. To learn more about tracking changes to
your Windows registry, check out the following resources:
Final Word 18
Useful References
If you want to master other Windows management skills, take a look at the following
resources:
Blog post | How to Add, Delete and Change Local Users and Groups with PowerShell
Manage
Blog post | Protecting Credentials in Windows Server 2016
How-to | How to Detect Who Installed What Software on Your Windows Server
Monitor
How-to | How to Detect Who Created a Scheduled Task on Windows Server
20
About Netwrix
Netwrix is a software company that enables information security and governance professionals to reclaim
control over sensitive, regulated and business-critical data, regardless of where it resides. Over 10,000
organizations worldwide rely on Netwrix solutions to secure sensitive data, realize the full business value
of enterprise content, pass compliance audits with less effort and expense, and increase the productivity
of IT teams and knowledge workers.
Founded in 2006, Netwrix has earned more than 150 industry awards and been named to both the Inc.
5000 and Deloitte Technology Fast 500 lists of the fastest growing companies in the U.S.
Next Steps
Free trial – Set up Netwrix in your own test environment: netwrix.com/freetrial