The following is a list of commands currently supported on the following Operating Systems:
Environment Variables
In general, an environment variable's name and value can be any ASCII character string; however, certain
strings are reserved or have special meanings. (See below.) You refer to the value of an environment variable
by enclosing it in "%
" characters. You can use these expressions with any of the above commands in place of
a literal value.
Example:
The command "showmessagebox %myVar%
" would display a message box containing the value of the variable myVar
.
Composition
You can compose the values of environment variables.
Example:
The two commands "set var1=Hello
" and "set var2=%var1% world!
" give var2
the value "Hello world!"
Substring
You can pull parts of information from a string and put them as a variable.
Example:
set Var1=Substring "Hi Hello World Goodbye" 4 11
Showmessagebox "%Var1%"
would show "Hello World" on the device screen.
Errorlevel
The system reserved variable errorlevel
always has an integral value. You can assign integer values to this variable, but you cannot delete it.
Example:
set errorlevel=9.
Variable Initialisation Using System Information
A number of special strings allow you to extract information from the device and store it in an environment variable. You can extract this information from the following five sources:
- Text file: To extract a line from a text file, use a string of the form
TXT://\<filename>?LN=<line number>.
Example:
The command "set myVar=TXT://policy.txt?LN=5
" stores line 5 of the file
policy.txt
in the variable myVar
.
- System registry: To extract a value from the registry, use a string of the form
"
REG://<key>?VN=<value name>
."
Example:
set myVar=REG://HKEY_LOCAL_MACHINE\Windows CE Tools?VN=Platform
.Ini
file: To extract a value from a .ini
file, use a string of the form
"INI://\<filename>?SC=<section>&NM=<name>
."
Example:
set myVar=INI://settings.ini?SC=Config&NM=PreferredOption
- Exit code: You can store the exit code of an executable program, but this does
not work on the Windows CE and Pocket PC platforms. Use a string of the form
"
EXE://<command line>
. "
Example:
The command "set myVar=EXE://scansystem /o
" runs the command
"scansystem /o
" and stores its return code in myVar
.
- STDOUT: You can store the first line of output from an executable program (only
supported on Windows 2000/XP platform). Use a string of the form "
STDOUT://<command line>
."
Example:
The command "set myVar=STDOUT://checkmessages
" runs the command
"checkmessages
" and stores the first line of its output in myVar
.
Windows Mobile and Desktop Script Commands
Command |
Description |
Example(s) |
@
|
Prefix any command by this character to stop the command from being displayed when executing commands in a script file.
|
To hide the output from the dir command:
@dir |
abortpkg
|
Aborts the installation of a package and forces it to show up as "Failed" in the MobiControl Manager, when used in a MobiControl Pre-Install script.
Please see the MobiControl Package Studio page for more details.
|
|
abortsync
|
Aborts the file synchronization process, when used in a MobiControl Pre-Sync script.
Please see the File Sync Rule page for more details.
|
To abort file synchronization if the first octet of the device's IP address is 169 (i.e. the IP is of the form 169.254.0.1 ):
set firstoctet=ipoctet %IP% 1
if %firstoctet%==169 abortsync |
attrib
|
Displays or changes file attributes.
Syntax:
attrib [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename]
"+ " 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.
|
attrib +A 1:\database_info.txt
|
cd
|
Changes the current directory.
|
To change to Windows directory:
cd Windows |
certimport
|
Imports a user-specified certificate of X.509 type, which could be either DER or Base64 encoded.
Syntax:
certimport -cert "<filepath>" -stype "<storagetype>" -storage "<storage>"
"<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 OSs support all 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> " specifies storage into which to import the certificate. Available
options are not supported by all OSs:
- "
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.
|
- 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 screen.
|
|
copy
|
Copies one or more files to another location.
Syntax:
copy <source> <destination>
Files can be copied between the desktop computer and mobile devices.
|
To copy files with the extension .txt from the c:\temp to the temp directory on the mobile device:
copy c:\temp\*.txt 1:\temp |
del
|
Deletes one or more files.
Syntax:
del <names>
|
To delete all files with the extension .tmp in the current directory:
del *.tmp |
dir
|
Displays a list of files and subdirectories in a directory.
Syntax:
dir [drive:][path][filename]
|
To list the files in Temp directory of the mobile device enter the following command. (The mobile device file system is denoted by 1: .)
dir 1:\Temp\ |
echo
|
Displays messages, or turns command-echoing on or off.
|
- To turn command echoing off:
echo off
- To turn command echoing on:
echo on
- To display the message "Copying Files ...":
echo Copying Files ...
|
exit
|
Close the remote help desk application window
|
|
find
|
Syntax:
find [/s] [filename]
"/s " is to search files in subfolders.
"filename " is the file specification for which you are searching.
|
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.
When a hard reset is initiated from a package's post-install script, the entire package will re-install
after the reset. A check can be included in the pre-install script that determines whether the
package's files have already been installed.
Notes:
- This command is of no consequence as a script command but only
useful in the event of a package that involves cold boot.
|
If a package's post-install script contains:
md "1:\PersistantStorage\subfolder" reset /w
Then the pre-install script could contain a check to prevent the package from being re-installed endlessly:
if exist "1:\PersistantStorage\subfolder" finishpkg
|
goto
|
Directs script execution to a labelled line in a script. This command is only for use in scripts.
|
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.
|
|
if
|
If errorlevel is greater than or equal to <number> (or less than <number> if "not" is present), then execute <command>:
if [not] errorlevel <number> <command>
If two operands are identical (not identical if "not" is present) execute <command>.
The operand can be a string constant or environment variable:
if [not] (<string> | %<environment variable>% ) == (<string> |
%<environment variable>%) <command>
If a file or folder exists (does not exist, if "not" is present) execute <command>.
If directory information is specified in the <file/folder name> then search in the directory,
otherwise search in current directory. Use 1:\ to specify device root folder:
if [not] exist <file/folder name> <command>
If <processname.extension> is found running in the memory of the device, then execute
<command> . If [not] is specified and the <processname.extension> is not found
running in memory, execute <command> :
if [not] procexists <Processname.extension> <command>
Notes:
<environment variable> and <string> can be any ASCII char string.
<command> can be any script command including the if command, which means the if command can be nested.
|
- if errorlevel 0 echo "errorlevel is greater/equal to 0"
if abc==%xyz% echo "value of environment variable xyz is equal to abc"
- If a variable contains white space, then the string must be within "".
if "%name%==John Smith" echo "This is John Smith"
if exist "1:\IPSM\abc.cab" echo "1:\IPSM\abc.cab exists"
if procexists filesys.exe echo yes
if errorlevel 0 if not errorlevel 1 echo "errorlevel is 0"
|
ipoctet
|
Returns the specified octet of an IP address and saves it to an environment variable, when called from within a MobiControl device script.
Syntax:
ipoctet <IP Address> <Octet number>
Please see the Environment Variables section below for more information.
|
- To save the value of the 4th 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 1st 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
|
Load the specified XML configuration file to the operating system.
This command is applicable only for Intermec devices with Intermec SmartSystems. The complete path for the XML file must be provided.
Syntax:
itcssconfig <xmlfile.xml>
This command will take the supplied XML file containing
the SmartSystems request and in return, create an output file in the same
directory with inserting *.out.* before the extension. The command
passes the XML files to SmartSystems API without modification, so it will
accept any valid request (either "Get" or "Set"). It's possible to use XML
files generated with SmartSystems Console.
Please see the Intermec SmartSystems Settings: Advanced XML Scripting page for more information.
|
itcssconfig 1:\FullPath\itcss.xml
Response:
itcss.out.xml
- 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
|
Terminate a process that is currently running on the mobile device.
Syntax:
kill <executable filename>
|
To terminate the pword.exe process on the mobile
device:
kill pword.exe |
log
|
Send a custom message back to MobiControl Deployment Server from the mobile device.
This message will show up in the LOG panel of the mobile device in the Devices View
(tab) in MobiControl Manager.
Syntax:
log <type> <message>
"log " is the command.
"<type> " is the type of message that should get associated. The options are:
- Error (
-e )
- Warning (
-w )
- Information (
-i )
"<message> " is the message that will be displayed in the device log in MobiControl Manager.
|
During a software push from MobiControl to your
mobile device, you can use this command to send notification to MobiControl Manager at certain intervals during the software push:
*** Command in the Pre-Install Script *** log -i "Starting Software Push" |
mkdir or md |
Creates a directory.
Syntax:
mkdir [drive:] < path>
|
- To create a directory called "test" from the current directory:
md test
- To create "test\test1\test2\test3" recursively:
md test \test1 \test2 \test3
|
move
|
This command moves a file from source specified to destination specified. You
can also rename the file being moved by specifying a different name for the destination filename.
Syntax:
move [source file path]<filename> <destination file path>[filename]
|
- To move a 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
|
pause
|
Prompts and waits for user input to continue. This command is only for use in scripts or .CMD files.
Syntax:
pause
|
Example:
pause Display:
Press any key to continue... |
ps
|
List the running processes on the mobile device.
|
|
regdelkey
|
Delete a key from registry on the mobile device.
Syntax:
regdelkey <registry key>
|
To delete registry key HKEY_CLASSES_ROOT\.2bp :
regdelkey HKEY_CLASSES_ROOT\.2bp |
regdelval
|
Delete a value from registry on the mobile device.
Syntax:
regdelval <registry key>\<value name>
|
To delete registry value HKEY_CURRENT_USER\Start\test :
regdelval HKEY_CURRENT_USER\Start\test |
registerdll
|
Register or unregister a DLL on the mobile device.
To register a DLL:
registerdll <dll filename>
To unregister a DLL:
registerdll -u <dll filename>
|
Register Example:
registerdll MCSetup.dll Unregister Example:
registerdll -u MCSetup.dll |
regload
|
Import a registration file to registry on the mobile device.
Syntax:
regload <registry file path>
|
To import registration file c:\test.reg to the mobile
device's registry:
regload c:\test.reg |
regsave
|
Export the mobile device registry subtree to a file.
Syntax:
regsave [-A | -U] [drive:][path]filename subtree[regpath]
"-A " is for ANSI format of output file.
"-U " is for UNICODE format of output file (default).
"[drive:][path]filename " is a file to where registry subtree will be saved.
"subtree[regpath] " specifies what part of device's registry will be exported. Possible values are:
- "
* " for everything (no 'regpath')
- "
HKLM " for HKEY_LOCAL_MACHINE
- "
HKCU " for HKEY_CURRENT_USER
HKCR for HKEY_CLASSES_ROOT
|
To export the HKEY_LOCAL_MACHINE subtree from the mobile device
registry to a UNICODE file C:\hklm.reg :
regsave -U C:\hklm.reg HKEY_LOCAL_MACHINE |
regset
|
Add a key or a value to registry on the mobile device.
Syntax:
regset <registry key> [value name] [data]
|
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
|
The rem command is used to insert a comment line in a script/batch file.
|
|
rename or ren |
Renames a file or folder.
Syntax:
rename <source filename> <destination filename>
|
To rename the file test.txt to test.bak :
ren test.txt test.bak |
replacetxt
|
This command allows to change all occurrences of a particular character or string in the specified file.
Syntax:
replacetxt <filename> <string to replace> <new string>
|
Example:
replacetxt "\Temp\My Device.txt" Device Psion |
reset
|
This command performs a Soft or Hard reset of the device.
Syntax:
reset [/S(Default)| /H | /W]
• reset /S (Default): To soft reset the device and also close the desktop remote control session if the device is being remote controlled.
• reset /H : To hard reset a device running Windows Pocket PC or Windows CE platforms. This command will result in clearing data stored in 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.
• reset /W : To perform the secure deletion of data stored on the device as well as a reset to
factory default settings. Please note that the wipe command is only supported on
the Windows Mobile 5 operating system with AKU2 or later and newer versions of Windows
Mobile.
|
- To soft reset a device:
reset
Note:
The reset /H or /W command will perform a system reboot similar to restart on Windows Desktop Agent.
|
resetpassword
|
Reset device password to new password
Syntax:
resetpassword <new password> |
To reset the user password on the device to "1234": resetpassword 1234
|
rmdir or rd |
Removes (deletes) a directory.
Syntax:
rmdir [/S] path
|
- To remove an empty directory called "Test" from the current directory:
rmdir test
- To remove a directory called "Test" and all of its contents:
rmdir /S test
|
sendsms
|
This script command can be used to send an outbound SMS (text message) from any online or ActiveSynced mobile device to 1 or more devices.
Syntax:
sendsms [recipient (s)] "[message]"
Separate recipient phone numbers with a semi-colon "; ".
|
- To send an SMS message to 1 number:
sendsms 416-555-0505 "This is a test message"
- To send an SMS message to multiple numbers:
sendsms 416-555-0505;905-555-5050;919-555-5500 "This is a test message"
Note:
The device receiving the SMS MUST have MobiControl installed in order for the command to complete successfully.
|
set
|
Set, edit or show values of environment variables.
Syntax:
"set " lists all environment variables.
"set <environment variable> " shows the value of <environment variable>
"set <environment variable>= " deletes <environment variable>
"set <environment variable>=<string> " sets the value of <environment variable> to <string>
"set <environment variable>=substring "<string>"
<startpos> [noofchars] " sets the value of <environment variable> to the string returned
by the substring command. (The substring command returns part of the string based on starting position
and number of characters specified.)
"set <environment variable>++ " increments the value of <environment variable> . The variable
must have an integer value.
"set <environment variable>-- " decrements the value of <environment variable> . The variable
must have an integer value.
|
- Set Var1=test will set the value of variable Var1 to "test"
- Set Var2=substring "testing" 1 4 will set the value of variable Var2 to "test"
|
setdate |
Sets the date, and time:
Syntax:
setdate <date> [time]
Usage: setdate <mm-dd-yyyy> [HH:MM:SS]
|
To set the date and time of
the device:
setdate 08-20-2009 13:32:00 |
shellexecute
|
Launches the registered application for the given file extension.
Syntax:
shellexecute <filepath> <-verb> [-w<seconds>]
|
To launch the registered application for the given file
extension:
shellexecute 1:\temp\temp.upg -open
shellexecute 1:\temp\temp.upg -run -w5 |
showmessagebox
|
Shows a message box on the device screen.
Syntax:
showmessagebox <message> [timeout] [type] [default button]
"<message> " is the message shown in the message box. Use quotation marks if there are spaces in the message.
"[timeout] " is the number of seconds until the message box is closed automatically. If [timeout] or if the keyword NO_TIMER is not present, the message box will be shown until user dismisses it. For MB_OK and
MB_ICONERROR message box types, timeout is optional.
"[type] " is the message box type (optional):
- "
MB_OK " is for an information window with an OK button.
- "
MB_YESNO " is for a question window with Yes (default) and No buttons
- "
MB_ICONEXCLAMATION " is for a warning window with an OK button
- "
MB_ICONQUESTION " is for a question window with OK (default) and Cancel buttons
- "
MB_ICONERROR " is for an error window with an OK button
"[default button] " (Optional) is for use with the keywords
YES and NO to set the default button for MB_YESNO and MB_ICONQUESTION .
In the case of MC_ICONQUESTION , YES is OK and NO is Cancel.
The return values for showmessagebox are stored in a global variable ShowMessageBoxReturn .
This variable can be used in scripts as %ShowMessageBoxReturn% to execute actions based on user interaction.
Possible return values are IDYES , IDNO , IDOK , IDCANCEL . The value for
this global variable does not change if the type is not MB_YESNO or MB_ICONQUESTION .
|
showmessagebox "This is a test message"
showmessagebox "Your device's IP address is %IP%"
showmessagebox "This is a test message with a 3 second timeout" 3
showmessagebox "This is a test message with Yes/No button and no timeout" NO_TIMER MB_YESNO
showmessagebox "Abort the operation?" NO_TIMER MB_ICONQUESTION YES if % ShowMessageBoxReturn %== IDYES goto Exit
|
sleep
|
Sleep for a specified number of seconds. This command is only for use in scripts.
|
Example:
sleep 5 |
sleepex
|
Sleep for a specified number of milliseconds. This command is only for use in scripts.
|
To sleep for 3.5 seconds:
sleepex 3500 |
smsreportpn
|
Sends a hidden encoded SMS message to a device to store it's current phone number in the registry.
Some SIM cards are not provisioned by the cellular carrier with their phone number post purchase. This prevents MobiControl from obtaining the devices phone number from the standard API calls used.
The smsreportpn command has been provided to acquire the devices current phone number via an SMS message exchange with another device running the MobiControl agent.
Upon completion of the message exchange the phone number is set in the following registry section:
"HKLM\Software\Apps\SOTI\" with the key name of "PhoneNumber"
The registry key value will be set on the target device.
Syntax:
smsreportpn <phone number>
|
The following command needs to be issued via MobiControl from a device that has SMS service. The phone number in the command is the phone number of the device in question.
To set a device's phone number's information:
smsreportpn 9675555555
Note:
There will be a total of two SMS messages, one from each device (The originating and target devices).
|
start
|
Start a program on the mobile device. When the "/wait " option is specified, the script processor waits for the started program to terminate before executing the next command in the script.
|
To start Pocket Word and wait until it is terminated:
start /wait pword |
type
|
Display the contents of an ASCII text file.
|
To display the contents of the file test.cmd :
type test.cmd |
uninstall
|
Removes the specified program from the device. This is equivalent to uninstalling a program by using the 'Remove Programs' applet in the device's control panel.
Syntax:
uninstall [/w] [program]
"/w " is to wait for the uninstallation to complete before proceeding in a script.
"program " is for the program to be removed.
The program name must be the complete name consisting of the application provider and the application name. This is the name that appears in the Remove Programs applet in the device's control panel.
|
To remove the program 1-Calc:
uninstall 1-Calc |
writeprofstring
|
Write a string into the specified section of an initialization file.
Syntax:
writeprofstring <filename> <section> [key] [value]
"filename " is the name of the .ini file.
"section " is the name of the section in the .ini file to
which the value is to be written. If the section does not exist, it is created. 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 entered, 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 quotes if the key or the value contain white space.
|
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
|
Load the specified XML configuration file to the operating system.
Syntax:
xmlconfig <xmlfile.xml>
This command will take the supplied XML file and load it onto the operating system.
This command 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 will allow you to script in complicated device
configuration schemas for easy deployment. Please see the Advanced XML Setup Script page for more details.
|
xmlconfig 1:\FullPath\xmlfile.xml
Note:
The complete path for the XML file must be provided.
|
1:
|
Select the drive/file system. The mobile device file system is denoted by 1: .
|
To switch to the c: drive on your desktop computer:
c: |
To run a program on the mobile device or to execute a script file. |
Enter the name of a program or command file followed by any command line arguments.
All script files must have the .cmd file extension.
|
- To get Pocket Word to open the document
notes.doc :
pword notes.doc
- To run a script file called "
test.cmd ":
test.cmd
|