Pre and post-installation scripts for Windows are typically used in application deployment scenarios to automate the app’s functioning before and after an application’s installation. These scripts allow you to perform system checks, and execute additional actions as needed.
Purpose
The purpose of this knowledge article is to provide instructions on using the scripts to automate the apps pre and post-installation of the applications.
Prerequisites
NA
Steps
- Pre-install script:
Pre-install scripts perform an action before installation occurs. For example, Admins can use it to set up all the necessary prerequisites before executing the msi/exe file that installs the application.
Before installing your applications, you may need to know system patch update availability or system requirements, services, or installation dependencies.
For example, before installing any application it is required to stop certain services (you can define the duration to stop the service and re-enable it once the app is installed) and then install the application. You must create a script to stop the respective service and then add a job to install the application.
The navigation to create the jobs are as follows:
- Goto Jobs > New Job > Select Windows Platform > Runscript Job > Enter the required script. Scripts can be Powershell, or shell script, as per your requirement.
- Create an Install job for the installation of the application once the above pre-install script is executed.
To know the complete steps on creating a job for the Application Installation via SureMDM, please refer to this article Job for installation of App
To know the complete steps on creating a job for the Application Uninstallation via SureMDM, please refer to this article Job for uninstallation of App - Now, create a composite job including the pre-install script created and the install job with some delay. To create a composite job, navigate to Jobs > New Job > Choose Windows platform > Composite Job > Add the Script job and install jobs created with some delay and save.
- Post-installation script:
The post-install script executes after the app installation has been completed. It’s used to perform additional configuration or cleanup tasks and app settings definition after the app is installed. The creation of the scripts and jobs is the same as the Pre-installation scripts procedure. Few post-install scripts may be based on Configuring System applications, Reduce storage size, Registering the App component, and many more.
These are sample examples. The specific tasks and commands in a pre-installation and post-installation script will depend on the requirements of the application being installed or getting uninstalled. Additionally, an Admin may need to be sure of the error handling aspect defined in the script for the app to get installed or uninstalled without any issues.
Need help? CONTACT US