I would like to uninstall an application using registry paths as this is what I can view in Defender for users devices.
When using the following command it works but a prompt is still coming up. I have tried adding different switches but not getting any where. Is this even possible if the app does not have a QuietUninstallString listed?
$paths = 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{6FB7DAEC-5DAD-491E-9951-4684423F291C}'
$app = Get-ItemProperty $paths | Select-Object UninstallString
$app.UninstallString | cmdThank you
Need PowerShell working script to uninstall software from Control Panel,Registry
Software Uninstaller Script (Silent)
uninstalling an application via uninstallString
uninstallation - Uninstall Chrome silently using Powershell - Stack Overflow
Videos
First of all, you have to check for the silent uninstall command.
For this purpose I usually use this tool: https://www.nirsoft.net/utils/uninstall_view.html
UninstallView is a tool for Windows that collects information about all programs installed on your system and displays the details of the installed programs in one table. You can use it to get installed programs information for your local system, for remote computer on your network, and for external hard-drive plugged to your computer. It also allows you to easily uninstall a software on your local computer and remote computer (Including quiet uninstall if the installer supports it).
The tool displays the silent uninstall command.
If you find the command, try it out manually. Sometimes, even a command is provided, silent uninstall doesn't work as expected.
Second, my recommendation is not to use WMI for uninstall, cause it is slow in determine the installed programs. Instead check for the registry key, which is also displayed by the tool.
To be more generic, read in these keys
HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
search for DisplayName with a where statement and execute the command in the quietuninstall key.
Uninstall an application silently
To uninstall an application, you can run the uninstall process as a startup script so it does not require any end-user input or interaction to complete the uninstall operation.
Since you are using PowerShell and already have logic you confirm uninstalls the application you need, the example provided will build off of that to keep it simple and basic.
Furthermore, beneath that I will provide an additional but different (and more efficient) way to uninstall the package using PowerShell since you are using Windows 10.
PowerShell Script (existing logic)
Note: Save this to
C:\Scripts\Test.ps1or on the local machine or perhaps a UNC path that you've grantedDomain Computersand/orAuthenticated Usersto the folder and the share.$app = Get-WmiObject -Class Win32_Product | ?{$_.name -eq "HP Support Assistant"}; $app.Uninstall();PowerShell Script (more effecient logic)
Note: This uses Get-Package with the package name and pipes that over to Uninstall-Package to uninstall the application from Windows.
$pName = "HP Support Assistant"; Get-Package $pName | Uninstall-Package;
Run as a startup script using Group Policy settings
Note: Use
gpedit.mscon the local machine to run the script as a Startup Script or if you are able use Group Policies from Active Directory if applicable in a domain environment.
- Go to
gpedit.msc - Navigate
Computer Configurations|Windows Settings|Scripts (Startup/Shutdown) - Click on
Startup|PowerShell Scriptstab |Addoption - Point the
Script Namefield to the full path of the startup script location Press
OKand/orApplyout of all existing screens to save the settingsLastly, you will just want to restart the computer to ensure the startup script runs and uninstalls the application without any need for user interaction or input.

Other Potential Solution
According to an answer on the HP Silent Uninstall HP Support Assistant post, you can also uninstall the HP Support Assistant application while logged on and not as a login script silently using:
"C:\Program Files (x86)\Hewlett-Packard\HP Support Framework\UninstallHPSA.exe" /s /v /qn
Supporting Resources
- Get-Package
- Uninstall-Package
You could use this PowerShell fragment :
$program = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match "Part of App Name" } | Select-Object -Property DisplayName, Uninstallstring, QuietUninstallString
start-process cmd.exe -argumentlist "/c ""
prog.quietUninstallString) /norestart""" -Wait
Where "Part of App Name" is enough to uniquely identify the product.
I was able to write a small PowerShell script for my specific need:
# Name of the software to check
$softwareName = "O365ProPlusRetail - de-de"
# Check if software is installed
$software = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.PSChildName -match $softwareName }
if ($software -ne $null) {
# Software is installed, uninstall it
& 'C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe' scenario=install scenariosubtype=uninstall sourcetype=None productstoremove=O365ProPlusRetail.16_de-de_x-none culture=de-de version.16=16.0 DisplayLevel=False forceappshutdown=true
Write-Host "$softwareName has been uninstalled."
}
else {
# Software is not installed
Write-Host "$softwareName is not installed."
}
it works for me but this is not a general solution.
Within PowerShell, this is very easy to do.
The below block of script will take a computer name, your username and password, connect to the remote computer and list all installed software by name:
$computerName = "SomeComputerName"
$yourAccount = Get-Credential
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_Product | Select Name
}
When you have the name of the product you want to uninstall remotely - you can the perform an uninstall like this:
$computerName = "SomeComputerName"
$appName = "AppName"
$yourAccount = Get-Credential
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_product | Where {$_.name -eq $appName} | ForEach {
$_.Uninstall()
}
}
In the above eaxmples - replace "SomeComputerName" with the name of the computer you wish to uninstall from.
You can also make the script prompt you for a computer name if you prefer with the following line:
$computerName = Read-Host "Enter Computer Name"
If you have multiple computers with the same piece of software that you want to uninstall - you can also define an array of computers to work with and do uninstalls from lots of machines:
$computerNames = @("SomeComputerName1", "SomeComputerName2", "SomeComputerName3")
$appName = "AppName"
$yourAccount = Get-Credential
ForEach ($computerName in $computerNames) {
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_product | Where {$_.name -eq $appName} | ForEach {
$_.Uninstall()
}
}
}
If you create a file called "servers.txt" and place your list of servers in it you could also reference $computerNames as follows:
$computerNames = Get-Content "C:\some-directory\servers.txt"
$appName = "AppName"
$yourAccount = Get-Credential
ForEach ($computerName in $computerNames) {
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_product | Where {$_.name -eq $appName} | ForEach {
$_.Uninstall()
}
}
}
I've used this approach many times in production environments and it seems to work for me. Always test this in a non-production environment before completing in a prod environment.
You need two more quotes around the argumentlist. This will force a reboot as they are uninstalled in my test. You could probably avoid that with an additional switch though.
Edit: this should be the final one.
$program = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match 'c\+\+ 2015-' } | Select-Object -Property DisplayName, Uninstallstring, QuietUninstallString
foreach($prog in $program){start-process cmd.exe -argumentlist "/c ""$($prog.quietUninstallString) /norestart""" -Wait}
Hi Experts,
I have to uninstall Microsoft Visual C++ 2019 X64 Additional Runtime - 14.29.30133 & Microsoft Visual C++ 2019 X86 Additional Runtime - 14.29.30133 software from my Control panel and Registry.
caa06090-a4f2-4a72-a496-f129b0aaa1ac-Control_panel.PNG745×163 50.5 KB
I have tried from the below powershell code, I am not getting any error. But Its not uninstalling. Not working.
Can someone provide me effective powershell script to uninstall it.
I am looking forward to hear from you.
$Myapp1 = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Microsoft Visual C++ 2019 X64 Additional Runtime - 14.29.30133"}
$Myapp1.Uninstall()
$Myapp2 = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Microsoft Visual C++ 2019 X86 Additional Runtime - 14.29.30133"}
$Myapp2.Uninstall()
Hey guys
here's the full script for who wants it, it is a simple script to uninstall multiple applications at once if you want. (Select multiple applications in the out-gridview and press "ok")
Be very careful using this script! Use it at your own risk and if you know what you are doing.
Any positive/negative criticism is always welcome in order for me to improve my skills.
Thank you!
$MsgIntro = @'
*********************** ***********************
Software Uninstaller Tool Made by PRIDEVisions
*********************** ***********************
'@
write-host -ForegroundColor Magenta "$MsgIntro"
Write-host -ForegroundColor Magenta "Please select the software you wish to uninstall..."
Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | select Displayname, InstallLocation, UninstallString | sort | Out-GridView -PassThru -OutVariable software
write-host -ForegroundColor Yellow "The following software will be uninstalled:"
foreach ($application in $software) {
write-host "$Application"
$uninstall = $Application.UnInstallString
cmd /c $uninstall /quiet /norestart
}Original question regarding this script: https://www.reddit.com/r/PowerShell/comments/7sdc0u/readhost_interrupting_script/
Edit: Quickly adjusted the script for both 32-bit & 64-bit software versions (It's not fully changed as i would like to but now it works better).
$MsgIntro = @'
*********************** ***********************
Software Uninstaller Tool Made by PRIdEVisions
*********************** ***********************
'@
write-host -ForegroundColor Magenta "$MsgIntro"
Write-host -ForegroundColor Magenta "Please select the software you wish to uninstall..."
$Software = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select DisplayName, UninstallString, InstallLocation, InstallDate | out-gridview -PassThru
write-host -ForegroundColor Yellow "The following software will be uninstalled:"
foreach ($application in $Software) {
if ($application.UninstallString -like "MsiExec*") {
write-host "$Application"
$uninstall = $Application.UnInstallString
cmd /c $uninstall /quiet /norestart
}
else {
$uninstall = $Application.UnInstallString
& "$uninstall"
}
}If it's an msi you can use uninstall-package:
get-package *chrome* | uninstall-package -whatif
instead of trying to use /X and remove /X and other things, try the following
# Get the key to uninstall
$chromeUninstall = $Chrome.Pspath.Split("\")[-1]
Start-Process -Wait -FilePath MsiExec.exe -Argumentlist "/X $ChromeUninstall /quiet /norestart"
or even simpler would be,
Start-Process -Wait cmd.exe -ArgumentList "/c msiexec /X $ChromeUninstall /quiet /norestart"
/c - Carries out the command specified by string and then terminates
Note
On my system I get two uninstall strings. You might want to think about looping or selecting first one in the list with the use of [0]
Hi,
Is there a way to run an uninstaller (.exe and no msiexec) script silently with no user prompt?
I’m trying to run this script but I still get a prompt to continue. I understand that silent uninstall only works on .msi / msiexec files. Any input is appreciated.
Script:
$unins = Get-ChildItem -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” -ErrorAction SilentlyContinue | Get-ItemProperty | Where-Object {$.Displayname -like “Advanced Monitoring*”} | Select Displayname, UninstallString
$unins = Get-ChildItem -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” -ErrorAction SilentlyContinue | Get-ItemProperty | Where-Object {$.Displayname -like “Advanced Monitoring Agent Network Management”} | Select Displayname, UninstallString
Start-Process -FilePath $unins.UninstallString -ArgumentList “/s”, “/qn” -Wait
Actually silent installs runs in CLI or command prompt with the correct switches (if available for that uninstaller).
I would recommend that you use a deployment tool like PDQ Deploy to test AFTER a google of the “silent installer” switches for that particular uninstaller (unless PDQ deploy have the uninstaller tool already)/
Hi all,
I've got a program I need to uninstall across about 50 or so machines in our fleet. I'm trying to write a Powershell script which will be deployed through Intune, but it doesn't appear to work when I test it on my machine. Full disclosure, as I'm very new to Powershell I asked ChatGPT to write it first, both to test ChatGPT, and to get a starting point if it didn't work. From what I can tell it looks like this script should absolutely work, but it just doesn't do anything and doesn't give me any errors.
# Check if the package is installed
$packageName = "Virtual Connect"
$packageInstalled = Get-Package -Name $packageName -ErrorAction SilentlyContinue
if ($packageInstalled) {
Write-Host "Uninstalling package: $packageName"
# Uninstall the package
Uninstall-Package -Name $packageName -Force
if ($?) {
Write-Host "Package '$packageName' was successfully uninstalled."
} else {
Write-Host "Failed to uninstall package '$packageName'."
}
} else {
Write-Host "Package '$packageName' is not installed."
}
Ideally what I'd like to do is have this app, 'Virtual Connect', uninstall silently. It's no longer in use across the organisation so best to just get rid of it entirely. Any advice would be greatly appreciated.