I've been asked for assistance with the following issue today. A developer has a CAB that he wants to install on the device without using CeAppMgr, from his own setup application. In addition he wanted to force the installation to the storage card if present.
This task involves several steps:
- Copy CAB to the device
- Detect storage card presence
- Launch wceload.exe to install the cab
1. Copying CAB to the device.
I would use cecopy (from Windows Mobile Developer Power Toys) or RAPI (CeCreateFile, CeWriteFile). If working with managed code, I suggest OpenNETCF.Communications library, or RapiDeploy tool
2. Detecting storage card presence.
While on the device side the preferred method is to use FindFirstFlashCard/FindNextFlashCard, these functions do not have Rapi equivalent. From the desktop side use CeFindAllFiles/FAF_FOLDERS_ONLY (or CeFindFirstFile/CeFindNextFile) to search the root directory and enumerate all files for having FILE_ATTRIBUTE_DIRECTORY and FILE_ATTRIBUTE_TEMPORARY combination of attributes (0x110).
3. Launch wceload.exe to install the cab
This is the interesting part. Here is a list of command-line switches that wceload.exe supports:
- /delete - if value = 0 do not delete cab after install
- /noui - perform a silent operation. Do not ask if it is ok to overwrite the exiting files
- /nouninstall - do not create a .uninstall file. The applciation entry will not appear in Remove Programs list
- /askdest - will force wceload to display a dialog that allows user to select installaltion location and some other things
- /noaskdest - install specified applications to specified locations (see below)
Dialog displayed by wceload when /askdest is specified
The /noaskdest switch is the most inetersting of them all. When you specify it, wceload ignores the rest of the command line. Instead it checks the following registry location - [HKEY_LOCAL_MACHINE\SOFTWARE\Apps\Microsoft Application Installer\Install]
The key contents are key/value pairs:
[CAB file path] = [CAB destination directory]
e.g. \Storage Card\MyApp.CAB = \Storage Card\Program Files\My App
wceload will try to install the cab specified in the value name to the location specified in the value value. Below is the sample registry content:
To reiterate: in order to install a cab to the memory card, one needs to:
- Copy CAB to the device (e.g. to the memory card)
- Create a registry value on the device specifying the cab location and cab destination
- Launch wceload.exe with /noaskdest parameter