How do I modify an Expandable String Value in the registry with PowerShell or a batch file?

1

0

I would like to use a PowerShell or batch script to modify an existing expandable string value to another. Specifically, I want to change the default value at

HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit\command

to

"C:\Program Files\Adobe\Adobe Photoshop CC 2015.5\Photoshop.exe" "%1"

I can do this directly in the registry editor, but when I export it as a .reg file, I get a bunch of hex nonsense; obviously that's not very intuitive:

enter image description here

So if I were to use an alternative method instead, such as PowerShell or a batch script, I would hope that I could actually read the path in plain text when viewing the code (since I can't inside the .reg file).

Can this be done with a PowerShell or batch script in a way that keeps the filepath readable?

jippyjoe4

Posted 2018-07-15T00:53:57.227

Reputation: 630

Is that the hex values translated in your screen shot? This means in that hex content, there is a human readable file that and that is what you want to see? – Pimp Juice IT – 2018-07-15T00:57:24.490

@PimpJuiceIT, yes, for some reason whenever you export an Expandable String Value from the registry, the exported .reg file looks like that, even though the actual content I entered into the registry editor field editor was exactly the string above with the path to Photoshop. Because it's so obscured, I hoped that using another method would make it easier to modify the path in the script file itself. – jippyjoe4 – 2018-07-15T00:59:51.290

Answers

1

This can be easily done using PowerShell

New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT

New-ItemProperty -Path "HKCR:\SystemFileAssociations\image\shell\edit\command" -Name "(Default)" -PropertyType ExpandString -Value '"C:\Program Files\Adobe\Adobe Photoshop CC 2015.5\Photoshop.exe" "%1"'

Read about it here

pun

Posted 2018-07-15T00:53:57.227

Reputation: 5 311