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.

  1. 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 granted Domain Computers and/or Authenticated Users to the folder and the share.

    $app = Get-WmiObject -Class Win32_Product | ?{$_.name -eq "HP Support Assistant"};
    $app.Uninstall();
    
  2. 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.

  1. Go to gpedit.msc
  2. Navigate Computer Configurations | Windows Settings | Scripts (Startup/Shutdown)
  3. Click on Startup | PowerShell Scripts tab | Add option
  4. Point the Script Name field to the full path of the startup script location
  5. Press OK and/or Apply out of all existing screens to save the settings

  6. Lastly, 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.

enter image description here


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