0
votes

I created a script to uninstall an application silently from the reg keys. It's worked for a few different apps without an issue. I'm trying to uninstall brave browser but, I keep getting this error below. I think the reason is because the uninstall string for brave is

C:\Program Files\BraveSoftware\Brave-Browser\Application\95.1.31.91\Installer\setup.exe" --uninstall --system-level.

The --uninstall and --system-level may be causing the error and I'm not to sure how to get around it.

Any ideas are greatly appreciated.

Error Message Below

Start-Process : This command cannot be run due to the error: The system cannot find the file specified. At line:11 char:40

  • ... isplayName){Start-Process -Wait -FilePath "$remove32" -ArgumentList "

$appName = "brave"

$32bit = get-itemproperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall*'| Where-Object { $.DisplayName -match "^$appName"} | Select-Object DisplayName, DisplayVersion, UninstallString| Where-Object { $.DisplayName -match "^$appName"}

$remove32 = $32bit.UninstallString

$64bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall*' | Where-Object { $.DisplayName -match "^$appName"} | Select-Object DisplayName, DisplayVersion, UninstallString | Where-Object { $.DisplayName -match "^$appName"}

$remove64 = $64bit.uninstallstring

if ($appName -like $32bit.DisplayName){Start-Process -Wait -FilePath $remove32 -ArgumentList "/S" -PassThru}

else {Start-Process -Wait -FilePath $remove64 -ArgumentList "/S" -PassThru}enter code here

The -filepath can only be C:\Program Files\BraveSoftware\Brave-Browser\Application\95.1.31.91\Installer\setup.exe. - js2010
Yes but that is the installer string. The uninstall string includes in the --uninstall and --system-level. That is the uninstall string that I'm trying to call. Any ideas on a way to get it working or a different method? - John418
You could try using the Get-Package | Uninstall-Package approach. For example. Use Get-Package to list packages. Say I wanted to remove audacity which is installed on my computer I could remove it by using: Get-Package "Audacity 3.0.3" | Uninstall-Package - Mogash
It would have to be something like start-process -filepath 'C:\Program Files\BraveSoftware\Brave-Browser\Application\95.1.31.91\Installer\setup.exe' -argumentlist '--uninstall','--system-level'. - js2010
Please try that you are able to uninstall the software manually by using the command line --uninstall and --system-level. If it works then the same command can be used in your script. - Dilly B