Uninstall an application without user input
Solution 1:
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.ps1
or on the local machine or perhaps a UNC path that you've grantedDomain Computers
and/orAuthenticated Users
to 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.msc
on 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 Scripts
tab |Add
option - Point the
Script Name
field to the full path of the startup script location Press
OK
and/orApply
out 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