Removing Client Applications

Programs configured with uninstall support will be removed when no longer advertised to clients, if that option has been chosen and correctly prepared when the application is installed (For more information, see “Removing Client Applications” earlier in this chapter.) Because a client can receive multiple advertisements for the same program, a program removal is not triggered until all of the advertisements for a program, from all sites the client is a member of, have been verified as revoked. An application is considered revoked when it is deleted, the client is no longer a member of the collection specified in the advertisement, or when an advertisement expires.

Each time a list of advertisements is successfully retrieved from a site’s CAP, the list is compared with the known list of advertisements, advertisements no longer received are noted, and the count of advertisements is decremented for the appropriate programs. Failure to retrieve a list of advertisements from a site does not cause those advertisements to be considered revoked. When the number of advertisements for a program with removal support reaches zero, its removal is triggered.

When triggered, the Advertised Programs Manager uses the registry key provided in the properties of the previously advertised setup program to locate the uninstall command line that should be executed. The uninstall command line is executed with the same properties used to execute the setup program, such as security context, whether or not a user can be logged on, and so forth. The uninstall command line is scheduled to run as an As Soon As Possible (ASAP) assignment. As with any ASAP assignments, if the conditions required for execution are met immediately, the uninstall program will run right away. If the conditions are not met right away, the program is put into a trigger list and will wait to run until the specified conditions are met. The set of status messages generated for program installations have removal-specific counterparts, and the removal status messages will reference the same advertisement as the setup program.

Removal of client programs is similar to the maintenance and removal of any software program, except that the client program must not require anything on the server for its removal. This should be tested carefully before the program is distributed.

Just as you must carefully test installation scripts, you must carefully test the uninstall script in order to minimize the number of problems and failures. Failures that do occur during removals are handled in the same manner as failures during installation, generating appropriate status messages but not automatically retrying the program’s removal. For both installations and removals, failed computers must be re-targeted with a follow-up advertisement. Recovering from this state is slightly more complicated for removals than for installations, as the existing installation program cannot simply be re-used. In the case of removals, this requires an additional uninstall program to be sent to the client to perform the clean up. Since all of the information to perform the application’s removal is already present on the client, the actual removal program can be as simple as a script that takes a command line parameter of the program’s uninstall registry key, looks up the command line on the client, and executes it. If the program itself provides an uninstall option in its setup and the package is still available to clients, the provided uninstall program could be advertised to clients.