Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Windows 10 Help with uninstalling a msi program with batch file

Mjk

New Member
Joined
Jun 7, 2024
Messages
3
I'm currently working on a script to uninstall a msi program that is installed on a client. The package doesn't have a GUID in registry but it does have its own uninstaller.exe I'm currently trying to use a msiexec /x %path/to/exe% /qn /f bat file to uninstall the package quietly without having any prompts while being ran through a scheduled logon task by GPO.

The issue I am having is that no matter how I change my script, a confirmation prompt always appears and it never uninstalls. Tried multiple ways but my knowledge is limited. Any help would be appreciated!!!
 
To uninstall a program using its uninstaller.exe via a batch file without user interaction, and managed by Group Policy, you might need to directly invoke the executable with silent/unattended switches rather than through msiexec. The typical issue you're encountering with msiexec is that it's designed to work with MSI packages and might not handle .exe uninstallation smoothly.

Below is a step-by-step guide to help you create a batch script for this purpose and deploy it via Group Policy:

### Step-by-Step Solution

1. Identifying Silent Uninstall Switches:
Most uninstallers (uninstaller.exe) support silent or unattended operation via specific command-line switches. Common switches include /silent, /verysilent, /quiet, /qn, etc. Check the documentation for the program you're trying to uninstall or run uninstaller.exe /? or uninstaller.exe /help to confirm the correct silent switch.

2. Creating the Batch File:
Create a batch file (uninstall_program.bat) with the following content. Replace C:\Path\To\Uninstaller\uninstaller.exe with the actual path to your uninstaller and the correct silent switch for your program.

Code:
@echo off
C:\Path\To\Uninstaller\uninstaller.exe /silent
exit /b %errorlevel%

If /silent does not work, try other common switches like /qn, /verysilent, or /quiet.

3. Deploying via Group Policy:
You can create a Group Policy Object (GPO) to run this script at logon. Here is how you can do that:

a. Open Group Policy Management:
- Press Win + R, type gpmc.msc, and press Enter to open Group Policy Management.

b. Create a New GPO:
  • Right-click on the domain or organizational unit (OU) where you want to apply the policy.
  • Click on Create a GPO in this domain, and Link it here....
  • Name your GPO (e.g., "Uninstall Program").

c. Edit the GPO:
  • Right-click your newly created GPO and select Edit.
  • Navigate to User Configuration -> Policies -> Windows Settings -> Scripts (Logon/Logoff).
  • Double-click Logon, then click Add... to add your batch file.

### Verifying and Troubleshooting
1. Test the Script Manually:
- Before deploying via GPO, run the script manually on a test machine to ensure it uninstalls the program without prompts.

2. Check Event Logs:
- If the script does not run as expected, check the Event Viewer on the client machine for errors under Applications and Services Logs -> Microsoft -> Windows -> GroupPolicy.

### Using PowerShell for More Control:
If batch files don't fulfill your need, you can also use PowerShell to achieve greater control. Here’s a PowerShell script example:

Code:
$uninstaller = "C:\Path\To\Uninstaller\uninstaller.exe"
Start-Process -FilePath $uninstaller -ArgumentList "/silent" -NoNewWindow -Wait

Deploy this script similarly via the GPO by placing it in the appropriate logon scripts section.

Using silent switches with uninstaller.exe directly should bypass the confirmation prompt that you are encountering. Make sure to replace the placeholder paths and switches with the correct ones for your specific package. Good luck, and feel free to ask more if you encounter any issues!
 
I've tried what has been suggested by AI but no luck. When using a batch file a prompt appears for "are you sure you want to uninstall" and if I use a pwershell script UAC authentication always pops up..
 
That is because of the security safeguards in Windows. If you want to run without UAC elevated, you need to run it at the highest runlevel for the operating system, or with admin credentials saved. This is significantly more complex than the basic information the bot has given you, but this would be the first steps you could take to automating your task.

The prompt you are getting from the batch file likely means you are running in the right context (privilege level/run level), but you have not passed uninstall parameters to the program or it does not have those parameters set properly. These are the argument flags you would use to call the file or the MSI file. The documentation for whatever app it is would hopefully be online or easily guessable.
 
Thanks for your response! So the program is actually software from the company I work at. The objective is to figure out and build a uninstall procedure without getting development involved. And I know, it's surprising that we don't actually have uninstall documentation for any of our software installations. #SaaS
 
Many uninstallers and organizations are hit or miss so I'm not surprised. :D
 
Back
Top