Category filter

Run scripts on Android devices

Running custom scripts allows IT administrators to instantly execute specific commands and automate complex device management tasks on Android devices. With Hexnode UEM, you can deploy both Android shell scripts and Hexnode custom scripts directly from your portal.

Prerequisites

Before you begin, ensure the following requirements are met:

  • The latest Hexnode Agent app must be installed on the target Android device.
  • Your script files must be in the correct format:
    • Android shell scripts: Must use the .sh format.
    • Hexnode custom scripts: Must use the .txt format.

Step-by-Step Configuration Guide

Follow these steps to deploy and execute a custom script on your managed Android devices:

  1. Log in to your Hexnode UEM portal.
  2. Navigate to the Manage tab and select the target device(s).
  3. Click on Actions > Deployments > Execute Custom Script.
  4. Select the script type you want to deploy:
    • Android shell script
    • Hexnode custom script
  5. Choose the script file source:
    • Global repository: Select from a pre-defined list of built-in scripts.
    • Local repository: Select a previously saved file from the Content tab, or generate a brand new script using Hexnode Genie.
    • Upload new file: Upload a script file directly from your local computer.
  6. Provide a name for the script, and click Execute.

Global Repository Capabilities

If you choose the Global repository, Hexnode provides a suite of ready-to-use scripts depending on the script type you selected.

1. Android Shell Script Capabilities (.sh)

These scripts are ideal for deep system, file, and app-level configurations.

Category Action Description & Requirements
App Management Uninstall application Uninstalls an application from the device.

Requirement: Works only for rooted devices.

Grant app permission Grants a specific permission to an app without user intervention.
Requirement: Works only for rooted devices.
Revoke app permission Removes a specific permission from an app.
Requirement: Works only for rooted devices.
Force stop app Forcefully terminates a running application and its background processes. Requirement: Works only for rooted devices.
Kill app processes Kills all background processes associated with a specific app.
Requirement: Works only for rooted devices.
File Management Create a folder Creates a new folder in the internal storage at a specified location.
Change directory Navigates to a different directory within the internal storage.
Rename file/folder Changes the name of a file or folder in the internal storage.
Move file/folder Moves a file or folder to a new location within the internal storage.
Delete file/folder Permanently removes a specific file or folder.
Device Control Reboot device Restarts the device.
Requirement: Works only for rooted devices.
Power off device Completely powers off the device.
Requirement: Works only for rooted devices.
Set system property Changes the value of a system-level property.
Requirement: Works only for rooted devices.
Activity Management Launch device home screen Navigates the device back to its main home screen.
Requirement: Works only for rooted devices.
Open URL Opens a web URL in the device’s default browser.
Requirement: Works only for rooted devices.
Open dialer with number Opens the phone dialer with a pre-entered number.
Requirement: Works only for rooted devices.
Device Administration Set device owner Assigns Hexnode UEM as the Device Owner for full policy control.
Requirement: Works only for rooted devices.
Activate device admin Activates device administrator rights for an app, granting special management privileges.
Requirement: Works only for rooted devices.

Run scripts on Android – Android shell script

2. Hexnode Custom Script Capabilities (.txt)

These scripts are tailored for MDM-specific actions and remote troubleshooting.

Category Action Description & Requirements
App Management Install application Installs apps from the app inventory directly to the device.
Uninstall application Uninstalls an application from the device.
Clear app data Clears the stored data for a selected app.
Requirement: Works only on Samsung Knox devices and Android Enterprise (AE) devices running Android 8 or below (AE < 9).
Device Control Lock device Locks the device and displays a custom message/phone number on the lock screen.
Power off device Completely powers off the device.
Reboot device Restarts the device.
Requirement: Works on rooted devices, or Android Enterprise devices running Android 6 or below (AE < 7) enrolled as Device Owner (DO).
Set password Sets a new password for the device.
Clear password Clears the device password if the user has forgotten it.
Enable lost mode Blocks all device features and locks it down with a custom message.
Requirement: Works on all devices except Profile Owner (PO) enrollments.
Disable lost mode Disables the lockdown, returning the device to its normal state.
Requirement: Works on all devices except Profile Owner (PO) enrollments.
Remote ring Plays a sound on the device even if the volume is muted.
Change ringtone Sets a custom ringtone on the device.
Import contacts Imports contacts from a vCard (.vcf) file to the device.
Activity Management Launch app Remotely launches a specified application or activity.
Note: For Profile Owner (PO) / Work Profile (WPC) enrollments, this only executes if the Hexnode app is currently open.
Launch Settings Remotely launches the device’s Settings app.
Note: For Profile Owner (PO) / Work Profile (WPC) enrollments, this only executes if the Hexnode app is currently open.
Launch device home screen Navigates the device back to its main home screen.
Note: For Profile Owner (PO) / Work Profile (WPC) enrollments, this only executes if the Hexnode app is currently open.
Open URL Opens a web URL in the device’s default browser.
Note: For Profile Owner (PO) / Work Profile (WPC) enrollments, this only executes if the Hexnode app is currently open.
Open dialer with number Opens the phone dialer with a pre-entered number.
Note: For Profile Owner (PO) / Work Profile (WPC) enrollments, this only executes if the Hexnode app is currently open.
Kiosk Management Enable kiosk mode Restricts the device to kiosk mode when the kiosk policy is active.
Requirement: Works on all devices except Profile Owner (PO) enrollments.
Disable kiosk mode Disables kiosk mode from the device.
Requirement: Works on all devices except Profile Owner (PO) enrollments.

Run scripts on Android – Hexnode custom scipt

What happens at the device end?

Once the script execution command is pushed from the Hexnode UEM portal, the Hexnode Agent on the Android device receives the payload. The script runs silently in the background (unless the script specifically commands a UI action, like opening the dialer or launching an app).

Remote Actions