Using Reg Add to Modify Default Value That Includes Spaces

Hi! This is my first time posting to this forum so hopefully I will not run afoul of any accepted practices on the forum.

I am trying to modify the value of a registry entry called (Default). I found an article from March, 2022 that claimed the (Default) value can only be modified using reg add. Following the example in that article, I was able to get the following command to work:

 reg add HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\LSD\4\Server\NfoPath\EasyLaw10 /d "\\ServerName\FolderName" /f

However, when I modify that command to the following, it does not work:

  reg add HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\LSD\4\Server\NfoPath\EasyLaw10 /d "\\ServerName\FolderName; C:\Program Files (x86)\Folder Name" /f

At the end of the day, the value of (Default) needs to end up as:

 \\ServerName\FolderName; C:\Program Files (x86)\Folder Name

I have tried various combinations of single and double quotes and escaping the spaces, but just can’t quite get it. I assume that this is less an issue with PowerShell, and more an issue with not properly handling the spaces in the folder path. I am posting here because I am thinking PowerShell might have a better way to make this kind of change, and if not, at least someone here will probably know the answer.

Thanks in advance for any help that you can offer!

–Tom

The PowerShell commands I’ve used for registry stuff are Get-ItemProperty and Set-ItemProperty, try to stick to native commands if possible.

$regPath = 'HKLM:\SOFTWARE\WOW6432Node\LSD\4\Server\NfoPath\EasyLaw10'
$newValue = '\\ServerName\FolderName; C:\Program Files (x86)\Folder Name'
#Get the current value of (Default) in case you need a backup
$originalValue = Get-ItemProperty -Path $regPath -Name '(Default)'
#Set the new value, remove -WhatIf to actually perform the change
Set-ItemProperty -Path $regPath -Name '(Default)' -Value $originalValue -WhatIf

Thanks! I will give that a try.

The reason that I was using reg add is that I found an article online that indicated reg add is the only way to change the (Default) value in the registry. Maybe that information is outdated, but the article is less than a year old, so I figured the information was more trustworthy than an article that is years old. Then again, if the information is just plain wrong, the age of the article doesn’t matter.

–Tom

That works beautifully! Thanks for the help!

–Tom

As far as I remember it never has been this way. Even with PowerShell version 2.0 you could set the Default values of registry keys.

You may contact the author of the article you’ve found to let him know that the information is misleading.

1 Like