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
- Test the Script Manually:
- Before deploying via GPO, run the script manually on a test machine to ensure it uninstalls the program without prompts.
- 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!