Script Commands for Windows Mobile Devices

Use the options and examples below to help you create your own powerful script commands.

Note: Not all script commands are compatible with all devices within a platform. Limitations are noted in the table entries.

Legend

Format Meaning
text Enter the command exactly as shown.
text Replace with the requested information.
[text] Information contained within square brackets is optional to the command.
text|text Choose one of the options separated by the vertical pipe.

Commands

Command Syntax
abortpkg

Halts the installation of a package and forces the installation status in the SOTI MobiControl console to report "Failed" when used in a SOTI MobiControl pre-install script.

See Using Package Studio for more information.

abortpkg
abortsync

When used in a SOTI MobiControl pre-sync script, it stops the file synchronization process.

See Using File Sync Rules for more information.

abortsync

Example

To abort file synchronization if the first octet of the device's IP address is 169 (when the IP is in the form 169.254.0.1):

set firstoctet=ipoctet %IP% 1

if %firstoctet%==169 abortsync

attrib

Displays or changes file attributes.

attrib [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename]

Where

  • + sets an attribute
  • - clears an attribute
  • R is the read-only file attribute
  • A is the archive file attribute
  • S is the system file attribute
  • H is the hidden file attribute

Example

To archive a file:

attrib +A 1:\database_info.txt

cd

Changes the current directory.

cd [directory]

Example

To change to the Chocolate directory:

cd Chocolate

certdelete

Deletes a certificate on the device.

certdelete -issuer "IssuerName" -sn "SerialNumber" -storage "storage"

Where

  • IssuerName is the common name of the certificate issuer
  • SerialNumber is the serial number of the certificate
  • storage is the type of storage into which to import the certificate

Example

To delete a certificate issued by apache.org:

certdelete -issuer "*.apache.org" -sn 00A03DB42A7841AFF5

certimport

Imports a user-specified certificate of X.509 type, which could be either DER or Base64 encoded.

certimport -cert "filepath" -stype "storagetype" -storage "Storage"

Where

  • filepath is the relative or absolute path of the certificate (.cer) file to import.
  • storagetype is the type of storage into which to import the certificate. Not all operating systems support all of the available options:
    • CSSCS is the current system service certificate storage
    • CSSCU is the current user certificate storage
    • CSSCUGP is the current user group policy certificate storage
    • CSSLM is the local machine certificate storage
    • CSSLME is the local machine enterprise certificate storage
    • CSSLMGP is the local machine group policy certificate storage
    • CSSS is the system services certificate storage
    • CSSU is the user's certificate storage
  • storage is the storage location into which to import the certificate. Not all operating systems support all of the available options
    • MY is the personal user certificate storage
    • ROOT is the root certificate storage.
    • CA is the certificate authority certificate storage
    • Trust is the trusted certificate storage
    • SPC is the software publisher certificate storage

Example

To import a certificate test.cer into current user storage of "MY" type:

certimport -cert "test.cer"

To import a certificate test.cer into root user storage of the local machine:

certimport -cert "test.cer" -storagetype "CSSLM" -storage "ROOT"

cls

Clears the device screen.

cls
copy

Copies one or more files to another location.

On Windows Mobile/CE and Desktop Classic devices, files can be copied between desktop computers and mobile devices.

On Android devices, files can only be copied locally.

copy source destination

Example

To copy all files with the extension .txt from the C:\ to the temp directory on the device:

C:\tempt\*.txt 1:\temp

del

Deletes one or more files.

del filename

Example

To delete example.txt in the current directory:

del example.txt

To delete all files with the extension .tmp in the current directory and its subfolders:

del *.tmp

dir

Displays a list of files and subdirectories in a directory.

dir [drive:][path][directoryName]

Example

To list the files in the Temp directory of the device:

dir 1:\Temp\

echo

Displays messages or switches command echoing on or off.

echo [on | off] or echo message

Example

To turn command echoing off:

echo off

To turn command echoing on:

echo on

To display the message "Copying Files ...":

echo Copying Files ...

exit

Closes the remote help desk application window.

exit
find

Finds a file on the device.

find [/S] [filename]

Where /S applies the search to any subfolders

Example

To search for all files with a .txt file extension including subfolders:

find /S *.txt

finishpkg

Finishes the current script without processing the rest of the package and reports package installation as successful to the deployment server. This is useful particularly in packages that involve wiping a device. This script command can be used to skip reinstalling the package but still report back as successfully installed to the deployment server.

If a hard reset is initiated from a package's post-install script, the entire package will reinstall after the reset. A check can be included in the pre-install script that determines whether the package's files have already been installed.

Note: This command is not useful as a script command in and of itself but in the event of a package that involves a cold boot.
"path\to\package"finishpkg

Example

"1:\PersistentStorage\subfolder" finishpkg

For platforms that support the if command, you use finishpkg conditionally: If a package's post-install script contains:

md "1:\PersistentStorage\subfolder"reset /w

then the pre-install script could contain a check to prevent the package from being reinstalled endlessly:

if exist "1:\PersistentStorage\subfolder" finishpkg

goto

Directs script execution to a labelled line in a script.

Only use this command in scripts.

goto label

Example

To go to label ":end"

copy *.* 1:\tmp

goto end

...

:end

help or ?

Displays a list of the commands supported and a brief description of each command.

help
if

Performs conditional actions if the specified conditions are found.

See The if Command for more information

install

Installs an application on the device.

install appInstallerPath

Where appInstallerPath is the full path to the application installer file on the device

Example

To install the Gmail app located in a Download folder:

install /sdcard/Download/Gmail.apk

ipoctet

Returns the specified octet of an IP address and saves it to an environment variable, when called from within a SOTI MobiControl device script.

ipoctet IPAddress octetNumber

Example

To save the value of the fourth octet of an IP address to the environment variable myOctet:

set myOctet=ipoctet 192.168.1.225 4 This gives myOctet the value 225

To save the value of the first octet of the device's IP address to an environment variable in a device script:

set myOctet=ipoctet %IP% 1 This gives myOctet the value 192 if the IP address is of the form 192.XXX.XXX.XXX

itcssconfig

Loads the specified XML configuration file to the operating system. You must provide the complete path to the XML file.

Note: This command is applicable only to Intermec devices with Intermec SmartSystems.

This command takes the supplied XML file containing the SmartSystems request and in return, creates an output file in the same directory with *.out.* inserted before the extension. The command passes the XML file to SmartSystems API without modification, so it will accept any valid request (either "Get" or "Set"). It is possible to use XML files generated with SmartSystems Console.

See Advanced Intermec SmartSystems Settings: XML Scripting for more information.

itcssconfig *.xml

itcssconfig 1:\FullPath\itcss.xml receives a response of itcss.out.xml

To generate an XML script that enables "Code 39" decoding in all devices in the Scanners group:


Subsystem Name="Data Collection"
    Group Name="Scanners" Instance="0"
        Group Name="Symbologies
            Group Name="Code 39"
                Field Name="Enable Code 39" 1/Field
            /Group
        /Group
    /Group
/Subsystem
								
kill

Terminates a process that is currently running on the device.

kill executable

Example

To terminate the pword.exe process on the device:

kill pword.exe

lockdevice

Activates the lockscreen on a device for the specified number of minutes.

Note: Minimum time is one minute.
lockdevice minutes

Example

To lock a device for 1 minute

lockdevice 1

log

Sends a customs message to the SOTI MobiControl deployment server from the device. This message appears in the Logs tab of the Device Information panel in the SOTI MobiControl console.

log type message

Where type is the type of the associated message and the options are:

  • -e for Error
  • -w for Warning
  • -i for Information

Example

To send a notification to the SOTI MobiControl console at certain intervals during a software push:

Note: Put the command in the pre-install script

log -i "Starting Software Push"

mkdir or md

Creates a new directory.

mkdir [drive:] path

Example

To create a directory named "test" from the current directory:

mkdir test

To create test\test1\test2\test3 recursively:

mkdir test \test1 \test2 \test3

move

Moves a file from specified source location to specified destination location.

Note: You can rename the file at the same time by specifying a name for the destination filename.
move [sourceFilePath] filename destinationFilePath [filename]

Example

To move the file test.bat:

move test.bat 2:\

move test.bat 2:\test.bat

To move and rename a file at the same time:

move 1:\test.bat 2:\test2.cmd

To move folder to root folder:

move Mars /

pause

Prompts device user and waits for user input to continue.

pause

Example

To show "Press any key to continue..." on the device screen:

pause

ps

Lists the running processes on the device.

ps
regdelkey

Deletes a key from registry on a device.

regdelkey registryKey

Example

To delete registry key HKEY_CLASSES_ROOT\.2bp: :

regdelkey HKEY_CLASSES_ROOT\.2bp:

regdelval

Deletes a value from the registry on a device.

regdelval registryKey valueName

Example

To delete registry value HKEY_CURRENT_USER\Start\test:

regdelval HKEY_CURRENT_USER\Start\test

registerdll

Registers or unregisters a DLL on the device.

registerdll [-U] dllFilename

Where -U is included when you want to unregister a dll

Example

To register a dll:

registerdll MCSetup.dll

To unregister a dll:

registerdll -U MCSetup.dll

regload

Imports a registration file to the registry on the device.

regload registryFilePath

Example

To import registration file c:\test.reg to the device's registry:

regload c:\test.reg

regsave

Exports the device registry subtree to a specified file.

regsave [-A | -U] [drive:] [path] filename subtree [regpath]

Where

  • -A specifies that the output file is in the ANSI format
  • -U specifies that the output file is in the Unicode format
  • drive: specifies the drive location where the registry subtree will be saved
  • path specifies the file path to the directory where the registry subtree will be saved
  • filename specifies the filename where the registry subtree will be saved
  • subtree specifies which part of the device's registry to export to a file. Possible values are:
    • * specifies everything
    • HKLM specifies HKEY_LOCAL_MACHINE
    • HKCU specifies HKEY_CURRENT_USER
    • HKCR specifies HKEY_CLASSES_ROOT

Example

To export the HKEY_LOCAL_MACHINE subtree from the device registry to a UNICODE file C:\hklm.reg:

regsave -U C:\hklm.reg HKEY_LOCAL_MACHINE

regset

Adds a key or a value to registry on the device.

regset registryKey [valueName] [data]

Example

To add a new key and two values to that key:

regset HKLM\software\apps testkey

regset HKLM\software\apps\testkey testvalue1 abc

regset HKLM \software \apps \testkey testvalue2 dword:123

rem

Inserts a comment line in a script/batch file.

rem [comment]

Example

To add a comment about pumpkins:

rem The pumpkins are looking great this harvest

rename

Renames a file or folder.

rename sourceFilename destinationFilename

Example

To rename the file test.txt to test.bak:

rename test.txt test.bak

replacetxt

Changes all occurrences of a particular character or string in the specified file to a new character or string.

replacetxt filename string/characterToReplace newString/Character

Example

To replace the "Device" string with the "Psion" string in the file My Device.txt in the temp folder:

replacetxt "\Temp\My Device.txt" Device Psion

reset

Performs a soft or hard reset of the device.

reset [/S | /H | /W | /E] [/delaysec]

Where

  • /S is the default option and soft resets the device. Any desktop remote control sessions will also be terminated.
  • /H is used to hard reset a device running on the Windows Pocket PC or Windows CE platforms. It clears any data stored in the volatile memory. On Windows Mobile 5.0 and later devices this is equivalent to a soft reset. The real-time clock may also reset depending on the device make and model.
  • /W is used to wipe data stored on the device and reset the device to factory default settings.
    Note: The wipe command is only supported on the Windows Mobile 5 operating system with AKU2 or later and newer versions of Windows Mobile.
  • /E is used to wipe data stored on the device and its external storage as well as reset the device to factory default settings.
  • /P is used to bypass factory reset protection. It is only supported on Android Enterprise Work Managed devices.

On Android Plus devices it is possible to specify a /delay parameter (in seconds): reset /S /delay 10

If /delay parameter is not defined, the default value is 5 seconds

Example

To soft reset a device:

reset /S

To reset an Android Plus device to its factory settings in 30 seconds:

reset /E /delay 30

resetpassword

Resets device password to new password.

resetpassword newPassword

Example

To reset current password to password12345

resetpassword password12345

rmdir or rd

Deletes a directory.

rmdir [/S] path

Where /S removes any subdirectories

On Android Plus and Linux devices, this command requires the /S option and will delete the specified item whether it is a directory or a file.

Example

To remove an empty directory named "test" from the current directory:

rmdir test

To remove a directory named "test" and all of its contents from the current directory:

rmdir /S test

To provide location:

rmdir /sdcard/Download/test

sendsms

Sends an outbound SMS (text message) from any online or ActiveSync enabled device to one or more devices.

The device receiving the SMS must have SOTI MobiControl installed for the command to complete successfully.

sendsms recipientPhoneNumber;recipientPhoneNumber "message"

Separate phone numbers with a semicolon.

Example

To send an SMS message to multiple numbers:

sendsms 4165550505;9055555050;9195555500 "This is a test message"

set

Sets, edits or shows values of environment variables.

set [environmentVariable] [=|++|--] [string]

Where

  • set used alone, lists all environment variables
  • = deletes the environment variable it is used with
  • ++ increases the value of the specified environment variable. The variable must have an integer value.
  • -- decreases the value of the specified environment variable. The variable must have an integer value.

You can also use set to set the value of an environment variable to the string returned by the substring command:

set environment variable=substring "string" startposition [numberOfCharacters]"

Example

To display all environment variables:

set

To set the value of the environment variable Var1 to test:

set Var1=test

To set the value of environment variable Var2 to test:

set Var2=substring testing 1 4

setdate

Sets the date and time.

setdate date [time]

Where date is in the following format: mm-dd-yyy and time is in the following format: HH:MM:SS

Example

To set the date and time of the device

setdate 08-20-2016 13:32:00

shellexecute

Launches the registered application for the given file extension.

shellexecute filepath -verb [-wseconds]

Where

  • -verb is the action you want the shell to execute
  • -w tells the command to wait for the specified length of time (in seconds) before executing

Example

To launch the registered application for the given file extension:

shellexecute 1:\temp\temp.upg -open then shellexecute 1:\temp\temp.upg -run -w5

showmessagebox

Displays a message box on the device screen.

Note: The Android Plus agent has the following limitations:
  • It does not support a complex showmessagebox that contains more than one command
  • It cannot return the user response
  • It does not support "if" and related keywords
showmessagebox message [timer] [type] [default button] [action]

Where

  • message is the message displayed in the message box. Use quotation marks (" ") if there are spaces in the message.
  • [timer] is the number of seconds until the message box disappears automatically. If you omit a timer value or add the keyword NO_TIMER, the message box will persist until the device user dismisses it.
  • [type] is type of of message box. Options are:
    • 1 displays an information window with an OK button
    • 2 displays a question window with Yes and No buttons
    • 3 displays a warning window with an OK button
    • 4 displays a question window with OK and Cancel buttons
    • 5 displays an error window with an OK button
  • [default button] sets the default buttons for message box types 2 (YES | NO) or 4 (OK | CANCEL)
  • NOTIFY_DEVICE notifies the device user of the message, depending on the notification settings applied to the device. That is, devices set to ring, will ring, set to vibrate, will vibrate, and muted devices will have no notification. Only supported on Android Plus devices with agents 14.0.0 or later.

The return values for the showmessagebox are stored in a global variable, ShowMessageBoxReturn This variable can be used in scripts as %ShowMessageBoxReturn% to execute actions based on user response. Possible return values are IDYES, IDNO, IDOK, IDCANCEL. The value for this global variable does not change if the type is not 2 or 4.

Example

To show a simple message:

showmessagebox "This is a test message"

To provide device information using a macro:

showmessagebox "Your device's IP address is %IP%"

To set a 3 second timer to your message:

showmessagebox "This is a test message with a 3 second timer" 3

To add YES and NO buttons to your message box with no timer

showmessagebox "This is a test message with Yes/No button and no timer" NO_TIMER 2

To provide followup actions to a user response to message box:

showmessagebox "Abort the operation?" NO_TIMER 2 YES
if %ShowMessageBoxReturn% == IDYES goto Exit
sleep

Initiates sleep mode on the device for a set period. Only use this command in scripts.

sleep [length]

Where length is in seconds

Example

To set the device to sleep for 5 seconds:

sleep 5

sleepex

Initiates sleep mode on the device for a set period. Only use this command in scripts.

sleep [length]

Where length is in milliseconds

Example

To set the device to sleep for 3.5 seconds:

sleep 3500

smsreportpn

Sends a hidden encoded SMS message to a device to store its current phone number in the registry.

Some SIM cards are not provisioned by the cellular carrier with their phone number post purchase. This prevents SOTI MobiControl from obtaining the devices phone number from the standard API calls.

smsreportpn acquires the device's current phone number via an SMS message exchange with another device running the SOTI MobiControl agent. When the exchange is completed, the phone number is set in the following registry section:

HKLM\Software\Apps\SOTI\ with the key name PhoneNumber

There will be two SMS messages, one from each device.

The registry key value is set on the target device.

smsreportpn phoneNumber

Example

To set a device's phone number information:

smsreportpn 9675555555

start

Starts a program on the device. When the /wait option is specified, the script processor waits for the initiated program to terminate before executing the next command in the script.

start [/wait] program
Note: On Windows devices, program must be enclosed in quotation marks.

Example

To start Pocket Word and wait until it is terminated:

start /wait "\software\apps\pword.exe"

turnoff

Shuts down the device. You can specify a delay (in milliseconds) before shutdown.

turnoff [time]

Example

To turn off the device in 3.5 seconds:

turnoff 3500

type

Displays the contents of a Unicode text file.

type filename

Example

To display the contents of the file test.cmd:

type test.cmd

uninstall

Removes the specified program from the device.

uninstall [/w] program

Where

  • /w delays the uninstallation for the specified amount of time in seconds
  • program is the program ID for the program you want to uninstall

Example

To remove the program Google Maps:

uninstall com.google.maps

writeprivateprofstring

Saves or deletes specified settings on a device.

See The writeprivateprofstring Command for more information.

writeprofstring

Writes a string into the specified section of an initialization file.

writeprofstring filename section [key] [value]

Where

  • filename is the name of the .ini file
  • section is the section in the .ini file where the value will be written. The name of the section is case-sensitive.
  • key is the name of the key. If the key does not exist in the specified section, it is created. If this parameter is not included, the entire section, including all entries within it, is deleted.
  • value is the string to be written to the file. If this parameter is not entered, the key is deleted

Use quotations (" ") if either the key or the value contains spaces.

Example

To set the Color key in the "Video" section of the \Movie\mov.ini file to a value of "Red":

writeprofstring \Movie\mov.ini Video Color Red

xmlconfig

Loads the specified XML configuration file to the operating system. This command takes the supplied XML file and loads it onto the operating system. It is only valid on devices running Pocket PC 2003 or later. The XML file is handled by Microsoft's configuration manager. Use of this command allows you to script in complicated device configuration schemas for easy deployment.

xmlconfig filename.xml

The complete filepath for the XML file must be provided.

Example

To load an xml file to the operating system:

xmlconfig 1:\FullPath\xmlfile.xml