Use > Server patching > Patch management for Windows > Patch management administration > Patch uninstallation > Specify install scripts for a Windows patch uninstallation

Specify install scripts for a Windows patch uninstallation

For each patch, you can specify a command or script to run before uninstallation or after uninstallation. A pre-uninstall script, for example, could check a certain condition on the managed server. If the condition is not met or if the pre-uninstall script fails, the patch would not be removed from a server. A pre-uninstall script could also be used to shut down a service or application before it is removed from a server. A post‑uninstall script could be used to perform a certain cleanup process on the managed server.

You can specify the following types of scripts to run on the managed server before or after a patch uninstallation:

  • Pre-Uninstall: A script that runs before the patch is removed from a managed server.
  • Post-Uninstall: A script that runs after the patch is removed from a managed server.

To specify a script:

  1. From the Uninstall Patch window, click Next to advance to the Pre & Post Actions step.

  2. Select the Pre-Uninstall or Post-Uninstall tab.

    You may specify different scripts and options on each of the tabs.

  3. Select Enable Script.

    This option enables the remainder of the fields on the tab. If Enable Script is not selected, the script will not run.

  4. Select either Saved Script or Ad-Hoc Script.

    A Saved Script has been previously stored in Server Automation with the SA Client. To specify the script, click Select.

    An Ad-Hoc script runs only for this operation and is not saved in Server Automation. Select the Type, such as .bat. In the Script box, enter the contents of the script, including the drive letter of where the script is located, such as echo dir>> C:\temp\preinstall1.log. If you do not enter a drive letter, the default is %SYSTEMDRIVE%, which is where the system folder of Windows is installed.

  5. If the script requires command-line flags, enter the flags in Commands.

  6. Specify the information in the User section. The script will be run by this user on the managed server.

  7. To stop the uninstallation if the script returns an error, select Error.