Below is a PowerShell script I am running on Windows 10 to uninstall HP Support Assistant but it keeps prompting the end-users for input and such, and this is what I need to prevent.
Question: How can I uninstall this application silently or without the need for user interaction?
Note: I am able to access these machines remotely with admin permissions.
PowerShell Script
$laptops = Get-Content "c:\scripts\laptops.txt";
$laptops | %{ $app = Get-WmiObject Win32_Product -ComputerName $_ | ?{$_.name -eq "HP Support Assistant"}; $app.Uninstall(); }; 0 2 Answers
First of all, you have to check for the silent uninstall command.
For this purpose I usually use this tool:
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.
0Uninstall 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