Purpose
This document outlines how to use Custom Actions to uninstall applications from a target machine.
Note: Uninstalling programs is done at users own risk. The following method utilizes the built in uninstaller of the program. Shavlik has no control or information on what will be removed when a program is uninstalled in this manner.
Locate Uninstall Command
WARNING: When dealing with the registry it is always good practice to make a backup of the registry first.
http://windows.microsoft.com/en-us/windows-vista/back-up-the-registry
Note: This document will use 7-Zip as an example.
When an application is installed it will typically create a registry key under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
-or-
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
Locate the program's entry within this hive.
Example: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2702-0920-000001000000}
The registry key entry should contain a value called: UninstallString
Right click this value, and choose Modify. In the Edit String box that appears, copy the Value Data:
The UninstallString can be run in a command prompt window to uninstall a program. Because of this we can similarly pass the string as a Custom Action through Protect.
Custom Action
This custom action uses the MsiExec.exe to delete a file. Because Custom Actions are run as the Local System account, they must be run in a silent/unattended/quiet mode as no prompts will show up on a target machine for a user.
- Create a NewDeployment Template;enter a Name for theTemplate, andSaveit.
- Alternatively - open an existingDeployment Templateyou wish to modify.
- Click theCustomActionstab.
- Click theNewoption.
- In the Custom Actions window, leave Step 1 as 'All deployments using this template', Step 2 will remain disabled, Step 3 set to 'Before any patches', and Step 4 enter the UninstallString copied earlier.
Note: Make sure to include a silent switch in the string, or while uninstalling, it will hang because of an unacknowledged prompt.
Note: Multiple commands can be placed into a batch file. If using this method, 'push' the batch file first in the custom action, then run the batch file.
Example:MsiExec.exe /quiet /norestart {23170F69-40C1-2702-0920-000001000000}
This will uninstall 7-Zip from the target machine with no user interaction (/quiet) and with no reboot after (/norestart).
- Deploy the null patch (or use with any other patch deployment) and before the patches are installed the command to delete the specific file will execute.
MsiExec.exe Info
Here is additional information and parameters that can be used when calling MsiExec.exe:
These are found by opening Command Prompt and entering: MsiExec.exe /?
msiexec /Option <Required Parameter> [Optional Parameter]
Install Options
</package | /i> <Product.msi>
Installs or configures a product
/a <Product.msi>
Administrative install - Installs a product on the network
/j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
Advertises a product - m to all users, u to current user
</uninstall | /x> <Product.msi | ProductCode>
Uninstalls the product
Display Options
/quiet
Quiet mode, no user interaction
/passive
Unattended mode - progress bar only
/q[n|b|r|f]
Sets user interface level
n - No UI
b - Basic UI
r - Reduced UI
f - Full UI (default)
/help
Help information
Restart Options
/norestart
Do not restart after the installation is complete
/promptrestart
Prompts the user for restart if necessary
/forcerestart
Always restart the computer after installation
Logging Options
/l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
i - Status messages
w - Nonfatal warnings
e - All error messages
a - Start up of actions
r - Action-specific records
u - User requests
c - Initial UI parameters
m - Out-of-memory or fatal exit information
o - Out-of-disk-space messages
p - Terminal properties
v - Verbose output
x - Extra debugging information
+ - Append to existing log file
! - Flush each line to the log
* - Log all information, except for v and x options
/log <LogFile>
Equivalent of /l* <LogFile>
Update Options
/update <Update1.msp>[;Update2.msp]
Applies update(s)
/uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
Remove update(s) for a product
Repair Options
/f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
Repairs a product
p - only if file is missing
o - if file is missing or an older version is installed (default)
e - if file is missing or an equal or older version is installed
d - if file is missing or a different version is installed
c - if file is missing or checksum does not match the calculated value
a - forces all files to be reinstalled
u - all required user-specific registry entries (default)
m - all required computer-specific registry entries (default)
s - all existing shortcuts (default)
v - runs from source and recaches local package
Setting Public Properties
[PROPERTY=PropertyValue]
Consult the Windows ® Installer SDK for additional documentation on the
command line syntax.
Copyright © Microsoft Corporation. All rights reserved.
Portions of this software are based in part on the work of the Independent JPEG Group.
Affected Product(s)
Protect Versions: All