What command allows you to view registry keys and values and import and export some or all of a registry?
Windows users can access and edit the Windows registry through the command line. Review the sections below for the version of Windows on your computer and information about registry edit commands and syntax. Show
Tip If you're attempting to edit the registry from the command line because you're unable to get to normal Windows, try first booting to Windows Safe Mode. Then, run Regedit from Safe Mode. Tip To open Windows registry in the command prompt, press Windows key+R, type cmd, and press Enter. In the Command Prompt, type regedit and press Enter. Microsoft Windows XP, Vista, 7, 8, 10, and 11 usersMicrosoft Windows XP and later users can view, edit, and modify their registry from the Command Prompt application using the reg command. See the reg command page for additional information and examples. Microsoft Windows 95, 98, ME, and 2000 usersNote The instructions in this section also work for later versions of Microsoft Windows. By default, Microsoft Windows 95, 98, ME, and 2000 users can import registry files from the command prompt using the Regedit command. Using this command and a registry file containing the proper commands, a user can add, remove, and otherwise edit the registry from the command line. If you want to import a registry file from the command line, you can use the Regedit command and the name of the file you want to import. For example, if the name of the file was hope.reg, type the following command. Regedit hope.reg The file hope.reg could contain the commands necessary to add and remove registry values. Below are examples of registry files to create entries, delete single entries, and a complete folder. To create these files yourself, copy the following examples into an empty .reg file or use notepad or the edit command to create a file using the following commands. Note Users running earlier versions of Windows may want to substitute Windows Registry Editor Version 5.00 with REGEDIT4. The following example adds a ComputerHope folder into the HKEY_LOCAL_MACHINE\Software directory with a string example and data value of data here. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope] "example"="data here" To delete a single entry in the registry, add a hyphen (minus) key after the equal sign. For example, if we wanted to delete our string value "example" we created with the above example, we would create the following .reg file. The Windows registry is a database that contains important, machine-specific settings and information regarding almost everything in your computer — preferences, applications, users, attached devices and so on. The registry contains two basic elements: keys and values. The Windows operating system is constantly referring to the registry; for example, to open a program, install new software or change your hardware, Windows must check the values of certain keys. A registry file can become corrupted due to malware or issues, which can lead to poor performance or even the operating system crashing. To ensure you can recover from corruption, you should back up your reg files regularly. So let’s find out how to make an entire registry backup and restore the registry in Windows. Handpicked related content:
Making a Windows Registry BackupBack up the Windows Registry Using RegeditBack up your registry regularly, and also before you attempt to change, create or remove registry settings or hives, or install new system drivers, so you can revert to a known good version if something goes wrong. Follow these steps to create a backup:
Backing up the Windows Registry Using the Command PromptYou can export registry records by typing reg export and a particular registry root key at the command prompt. To export multiple keys, you can use a script like the following: reg export HKCR C:\RegBack\HKCR.Reg /y reg export HKCU C:\RegBack\HKCU.Reg /y reg export HKLM C:\RegBack\HKLM.Reg /y reg export HKU C:\RegBack\HKU.Reg /y reg export HKCC C:\RegBackHKCC.Reg /y You can also back up your registry automatically with third-party registry cleaning software like CCleaner Registry Cleaner; you can find more about top free tools in the article “How to Perform Windows Registry Repair.” Restoring the Windows RegistryYou can restore your registry in several different ways. Here are the most common methods:
How to Restore a Registry Backup from Safe ModeThis is the most basic method. First, boot Windows in Safe Mode by pressing the F8 button while turning your computer on. When you boot in Safe Mode, Windows loads 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 commands:
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. How to Restore the Registry from the Command PromptIn some situations, the Windows system will not boot into Safe Mode, so you need to manually restore your registry from the command prompt. To do this, you’ll need your original Windows OS disk or an ISO image on the bootable flash drive with your Windows operating system. Tap the F8 button before Windows starts and choose Repair My Computer. If F8 doesn’t work, boot from your CD or flash drive by selecting your CD-ROM or flash drive as a primary bootable device in the BIOS and enter the repair Windows mode from there. After booting the Windows OS setup, go to System Recovery and select the command prompt. We’ll be assuming your Windows directory is located on the C drive. Enter these commands 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 .. Note that the two periods are part of the command. After this process completes, restart your computer. How to Restore the Windows Registry with System RestoreYou can also restore your computer’s registry using a Windows system restore point. If your computer has 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 create restore points manually.
How to Restore the Registry with Automatic RepairNewer versions of Microsoft Windows, starting from Windows XP, include an automatic repair feature. When you run Automatic Repair, it will attempt to fix corrupt 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):
How to Restore the Registry with System File CheckerAnother way to fix a corrupted registry is to run the System File Checker:
How to Restore the Registry by Resetting the PCWindows 10 allows you to reset your computer and leave all your files untouched. This option completely refreshes your system files and may help with restoring the registry after a system crash. Here are the steps to follow:
Perform a Registry Restore with the DISM Command
Reinstalling Windows from ScratchIf these methods didn’t fix your registry problems, then you probably will have to reinstall Windows from scratch, which will reset the registry to factory settings. ConclusionYou 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, driver or device causes issues. It is also important to track changes to your registry entries to quickly spot registry corruption. In particular, malware often changes registry startup keys so it will start automatically after each reboot. You can learn more about tracking Windows Server registry changes in this guide about detecting modifications to startup items in the Windows registry. Handpicked related content:
Jeff Melnick Jeff is a former Director of Global Solutions Engineering at Netwrix. He is a long-time Netwrix blogger, speaker, and presenter. In the Netwrix blog, Jeff shares lifehacks, tips and tricks that can dramatically improve your system administration experience. How to export registry key from command line?Type “regedit” to open the registry editor and press Enter. Click File > Export. 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.
Which command can be used to export a registry key from a running machine?For example, typing: Regedit /e full. reg would export the full registry to the full. reg file. This switch can also be used to export individual registry keys.
What is the command to open the registry from a command prompt?Press Windows + R, type cmd and hit Enter to open Command Prompt on Windows 10. Then you can type regedit in Command Prompt window to open Registry Editor.
Which command is used to access the registry?Right-click Start , then select Run. Type regedit in the Open: box, and then select OK.
|