In a SureMDM setup for Android, Pre and Post Deployment Scripts help make the app installation process smoother and more reliable. Pre-deployment scripts run before the app is installed and are usually used to prepare the device, for example, by removing an older version of the app, clearing unnecessary files, etc. Post-Deployment Scripts, on the other hand, run after the app has been installed.
These are helpful for tasks like setting up the app with the right configurations, granting the necessary permissions, and automatically launching the app. By using these scripts, organizations can reduce errors, save time, and ensure that apps are installed and ready to use without needing manual steps.
Purpose
This article explains how to install an Android application (APK) using a SureMDM Job with the help of pre- and post-scripts. These scripts can be used for pre-configuration, logging, permission handling, or post-install actions such as launching the app.
Prerequisites
The SureMDM agent version should be equal to or higher than v27.53.00.
STEPS
- Log in to the SureMDM console. Goto Jobs > New Job >> Android >> Install Application.


- Click on Add to add the application that needs to be installed on the device.

- Enable the option Pre and Post Deployment Scripts to execute the pre-scripts or post-scripts for the associated app installation.
- In the highlighted section, you can paste or write scripts under the Pre-Deployment Script or Post-Deployment Script fields. These scripts help in automating actions such as uninstalling previous versions, granting runtime permissions, or launching the app, either before or after the app is installed on the device.
Example :
Post Deployment Script
The Astro contact application is uploaded to the job, and in the post-script box, the auto-launch script is added. When the job is deployed, on the device end the Astro contact application will install, and the app launches automatically.
Console End:
Device End Result:
Example:
Pre-Deployment Script
Using the Pre-Script, the new version of the SureLock is removed, and the old version of the SureLock is installed in a single job.
Console end:


Device End Result:
- The specific SureLock version 21.48.13 will get installed after the uninstallation of the existing version of SureLock.
Need help?