WARNING: READ THIS BEFORE YOU START
- Back up first. Part 5 makes a restore point and an export before anything is written.
- Never edit unfamiliar keys. In this lab you only look at real keys. You write only inside one test key that you create yourself:
HKCU\Software\LearningLab.- Do not touch
HKLMexcept to read it. A mistake inHKLMcan stop Windows from booting.- There is no Undo in
regedit. A deleted key is gone at once.- At the end, delete the test key (Part 8).
- If any command is not on this page, do not run it.
Objective
Explore the registry with your own eyes and your own hands, safely. You will read keys, see the five root keys and the types, look at the startup (Run) keys, create a test key, change it, export it, and remove it. You will see the chain from Section 11 happen on a small scale.
Time: 30–40 minutes
You need: A Windows PC. No extra software. A normal (non-admin) window is enough for everything here.
What to Open
| Tool | How to open it |
|---|---|
| Registry Editor | Press Win + R, type regedit, press Enter (click Yes if asked) |
| PowerShell | Press Win, type PowerShell, press Enter (normal, not admin) |
| Command Prompt | Press Win, type cmd, press Enter |
| Notepad | Press Win, type Notepad, press Enter |
Part 1: Look Around (Read Only)
Open regedit. Click Computer at the top of the left pane.
- How many root keys do you see? ________________
- Which two are the real roots (Section 2)? ________________
- Which root key is a merged view of two places? ________________
Now go to this key. (Paste the path into the address bar at the top of regedit, then press Enter.)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
Read, but do not double-click any value:
- ProductName: ________________
- CurrentBuild: ________________
- Type column for
ProductName(the type from Section 4): ________________ - Type column for
InstallDateorUBR(a number): ________________
Part 2: Ask the Command Line (Read Only)
In Command Prompt:
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName
reg query "HKCU\Control Panel\Desktop" /v WallPaper
In PowerShell, the same facts a different way:
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | Select-Object ProductName, CurrentBuild
Get-ChildItem HKLM:\SOFTWARE | Select-Object -First 10 Name- Does the first
reg queryshow the same name you read inregedit? ________________ - Which commands needed no administrator rights? ________________
Part 3: Startup Programs (Run Keys, Read Only)
Section 9 told you the Run keys decide what starts at sign-in. Look at them:
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
In regedit, visit both keys and see the names and the data (the command line):
- How many values are in the
HKCURun key? ________________ - How many in the
HKLMRun key? ________________ - Pick one entry. Which program does it start? ________________
You are allowed to look. To turn a startup app off, use Settings → Apps → Startup or Task Manager's Startup apps tab. Do not delete values here.
Part 4: See the Hive Files (Read Only)
Get-ChildItem $env:USERPROFILE -Force -Filter "NTUSER.DAT*" | Select-Object Name, Length
Get-ChildItem C:\Windows\System32\config -Force | Select-Object Name, Length- Do you see
NTUSER.DATand its.LOG1and.LOG2files? ________________ - The second command may say access denied for a normal user. Why (Section 6)? ________________
Part 5: Make a Safety Net
Before any write, do two things.
5A. Create a restore point (Section 10.2): press Win, type Create a restore point, choose your C: drive, make sure protection is On (otherwise click Configure and turn it on), click Create, name it Before registry lab.
5B. Export the parent key to a temporary folder. We export HKCU\Software so there is a copy of the area we will work in:
reg export "HKCU\Software" "%TEMP%\HKCU-Software-backup.reg" /y
- Open
%TEMP%\HKCU-Software-backup.regin Notepad (just read). Is it plain text? ________________
(It may be large. Close Notepad when done.)
Part 6: Create and Use a Test Key
Everything below happens in HKCU\Software\LearningLab, which does not exist yet and which nothing else uses.
6A. Create it with reg add:
reg add "HKCU\Software\LearningLab" /v UserName /t REG_SZ /d "Rover" /f
reg add "HKCU\Software\LearningLab" /v Volume /t REG_DWORD /d 50 /f
reg query "HKCU\Software\LearningLab"
/vis the value name,/tis the type,/dis the data,/fmeans "do not ask".
- What does the query show for Volume (hex and decimal)? ________________
6B. Look at it in regedit. Go to HKEY_CURRENT_USER\Software\LearningLab. Press F5 to refresh. Double-click Volume. Notice the Base choice (Hexadecimal or Decimal). Click Cancel.
6C. Change a value with PowerShell:
Get-ItemProperty HKCU:\Software\LearningLab
Set-ItemProperty HKCU:\Software\LearningLab -Name Volume -Value 80
Get-ItemProperty HKCU:\Software\LearningLab- What was the value before and after? ________________
6D. Add a second key and a list value with PowerShell:
New-Item HKCU:\Software\LearningLab\Settings
New-ItemProperty HKCU:\Software\LearningLab\Settings -Name Colors -PropertyType MultiString -Value @("red","blue","green")
Get-ChildItem HKCU:\Software\LearningLab- In
regedit, what type doesColorshave? ________________ How do the three items show when you open it? ________________
6E. Prove the "no Save button" rule (Section 11.2). Keep regedit open on LearningLab. In a terminal run:
reg add "HKCU\Software\LearningLab" /v Volume /t REG_DWORD /d 25 /f
Look at regedit before pressing F5, then press F5.
- Did the value change on its own, or only after refresh? ________________ (Programs can ask to be notified, Section 11.3;
regeditdoes not always repaint at once.)
Part 7: Export the Test Key
reg export "HKCU\Software\LearningLab" "%TEMP%\LearningLab.reg" /y
Open %TEMP%\LearningLab.reg in Notepad.
- Find the
"Volume"=dword:...line. What number is written, and is it hex or decimal? ________________
Now simulate a mistake and a repair:
reg add "HKCU\Software\LearningLab" /v Volume /t REG_DWORD /d 99 /f
reg import "%TEMP%\LearningLab.reg"
reg query "HKCU\Software\LearningLab" /v Volume
- What is
Volumeafter the import? ________________ (This is why you export first.)
Part 8: Clean Up (Important)
Delete only the test key, using either method:
reg delete "HKCU\Software\LearningLab" /f
or
Remove-Item HKCU:\Software\LearningLab -RecurseThen confirm it is gone, and remove the temporary files:
reg query "HKCU\Software\LearningLab"
del "%TEMP%\LearningLab.reg"
del "%TEMP%\HKCU-Software-backup.reg"
- What does the final
reg querysay? ________________ (Expected: the system cannot find the key.)
What Should Happen
- Part 1 and 2 show the same Windows facts through
regedit,reg, and PowerShell. - Part 3 shows what starts at sign-in.
- Part 4 shows that hive files exist but are protected.
- Part 6 and 7 show create, read, change, export, mistake, and repair on a safe key.
- Part 8 leaves your registry as you found it.
Interpretation Guide
| What you see | What it means |
|---|---|
REG_SZ for ProductName | Text value (Section 4.1) |
Version values shown as 0x... with a decimal in brackets | REG_DWORD (Section 4.2) |
reg query says "unable to find the specified registry key" | The key does not exist (expected after clean-up) |
Access denied on System32\config | Permissions at work (Section 6) |
UserChoice or other protected keys will not open | Windows guards them on purpose |
import brings back the old value but a new value remains | Import does not delete values added later (Section 10.3) |
| Entries in the HKLM Run key | Programs that start for every user |
Follow-Up Questions
- Why did this lab write only to
HKCUand never toHKLM? - In Part 6E, which steps of the Section 11 chain happened when
reg addran? - After the lazy flush (Section 11.2), where is
Volumestored on disk? Which file? - If you had changed a value that a running program reads only at startup, what would you do to see the change?
- Name two things that could go wrong if you edited an unfamiliar key in
HKLM\SYSTEM.