Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
4/8/2010

The autorun feature, which is part of the OS, enables Windows Mobile software to do the following:

Renaming any executable file to Autorun.exe causes it to launch automatically when the card is inserted into the device. The Autorun.exe file must be in a directory whose name coincides with the processor type value of the device. To take advantage of this feature, add the following file structure and file to a storage card:

Copy Code
\<
processor type value>\autorun.exe

For example, the folder name 2577 signifies an ARM processor. This is the typical processor for a device running Pocket PC 2002 or later. For this processor, the file structure is as follows:

Copy Code
\2577\autorun.exe

See SHGetAutoRunPathfor a list of applicable folder names for other processor models.

When a user inserts a storage card, the Windows Mobile software does the following:

  1. Searches the root directory of the card for a directory named with the appropriate processor code for that device.

  2. Searches this directory for the Autorun.exe file, and loads this file to the \Windows directory in main memory on the device.

  3. Invokes the copy of Autorun.exe on the device, passing it the command-line argument install.

When the user removes the card, Windows Mobile does the following:

The software also detects whether a card is inserted, removed, or swapped while the power is off and takes appropriate action as soon as the device is turned on.

You can determine the source directory for the Autorun.exe file with the SHGetAutoRunPathfunction. A storage card must be inserted for this function to succeed, although Autorun.exe does not need to be present on the storage card. This function creates the directory path, based on the present processor and returns it as a string variable.

Scenarios

A game developer can store game binaries and data files on a storage card. The developer can then design the Autorun.exe file that adds registry settings and loads necessary files when the storage card is inserted into the device and removes these settings and files when the card is removed. If the game must retrieve its home path, SHGetAutoRunPathreturns it in a string variable.

In an enterprise application, Autorun.exe can be used to deploy a custom software application and data to a large number of devices. Updates to the application can be distributed to remote employees on inexpensive, low-capacity storage cards that perform automatic and trouble-free installation when inserted into the devices.

If users must cold boot or replace their devices, they can insert a preprogrammed storage card that contains the application and data and turn their device on. The autorun feature then launches the Autorun.exe application and performs the programmed actions.

See Also