Saturday, 1 December 2018

Updating Registry Values

PowerShell is simply superb. Windows changed the world by giving a computer for every Home. I love Windows and prefer Windows over Mac, since looks are always deceptive.

As a kid, I used to play on Windows games like Xatax and enjoyed BASICs programming in school. I had to type in the command prompt to login to Windows. Windows can be modified using Registry values. Just as A,B,C is fundamental to English. Registry values are low level Windows Fundamentals. This contains many Windows Configuration details.

You can open the Registry Editor by typing "regedit" in the command prompt(Start->Run). You are advised not to change any settings unless you are an administrator. In case , you are changing, take a backup and then change.The registry contains Key Value pairs.They are grouped under various folder like locations like HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG. They are called hives, because the original Windows developer of NT version hated bees.

How can we view the registry values in PowerShell,example of HKEY_CURRENT_USER?
Make sure you have permission to view the folder:
READ:
Get-ChildItem -Path Registry::HKEY_CURRENT_USER

CREATE:
1. Take a backup of Registry using File->Export 
Save in a location like c:\backup\registry\backup.reg
You can restore in case of any errors by using File->Import from above location.

2. Suppose you want to add a "Open with notepad" icon, you need to add a registry value to 
"Open with notepad" under shell location
Change the value to notepad.exe %1

Below are the commands:
Push-Location
Set-Location -Path Registry::HKEY_CLASSES_ROOT
Test-Path ".\*\shell\Open With Notepad"
Set-Location -LiteralPath "Registry::HKEY_CLASSES_ROOT\*\shell"
New-Item -Name "Open With Notepad"
Set-Location -LiteralPath  "Registry::HKEY_CLASSES_ROOT\*\shell\Open With Notepad"
New-Item -Name "command"


UPDATE
Use Set-Item to update the key value
Set-Item  -LiteralPath "Registry::HKEY_CLASSES_ROOT\*\shell\Open With Notepad\command" -Value "notepad %1"



Reference:




No comments:

Post a Comment