Forum Discussion
robmo
Jan 25, 2023Brass Contributor
Remove extra set of double quotes in string
Hi, I am writing a PowerShell script that needs to remove Firefox that is less than or equal to a specific version. I have the script working up to where it reads the uninstall string from the regis...
- Jan 30, 2023I did some inspection of Firefox installations and it turns out that they use the same uninstall string for every version. The only difference is if helper.exe is in Program Files (x86) or Program Files:
C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe OR
C:\Program Files\Mozilla Firefox\uninstall\helper.exe
Since I have this information, I will just set some variables for these strings and then I won't have to deal with string handling when reading from the registry. This will simplify the development of this script.
Thank you for your help!
Jan 25, 2023
This should work : $uninstall= $uninstall -replace ('""'),('"')
- robmoJan 25, 2023Brass Contributor
Harm_Veenstra,
What would be a good way to test if this solution works? I am using the following code but it fails at the initial assignment on Line 1 and throws an error:$uninstall = ""C:\Program Files\Mozilla Firefox\uninstall\helper.exe"" $uninstall = $uninstall -replace('""'),('"') $uninstall
Perhaps I need to use string handling at the time the value is retrieved from the registry?
- Jan 25, 2023Ah, ok.. You should use $uninstall='"C:\Program Files\Mozilla Firefox\uninstall\helper.exe"' to escape the double "
- Jan 26, 2023And how do you retrieve the value, perhaps we can fix that so that it's OK from the start