Go back

Creating an Installer for Windows Mobile Applications

We recently had a requirement come up to create a windows installer for a mobile application. So a couple of minutes of googling gets me a great MSDN article on step by step instructions on creating an installer.

However, great as MSDN is, the article had some flaws, it didn't work! The application installed on the local windows machine but didn't trigger the mobile install on the device.

After some debugging of the installer code, I found that the article refers to Context.Parameters["InstallDirectory"] however it asks you to place targetdir="[TARGETDIR]" in the CustomActionData property. This meant the install directory was not being transfered to the DLL.

To make the project work you need to get those two to match. Update the code to use Context.Parameters["TargetDir"] and everything works a treat.

Remember to set both Commit and Install custom actions to the new DLL otherwise it won't install correctly.

The final code looks like:


/// Code implemented from: http://msdn.microsoft.com/en-us/library/bb158529.aspx

public partial class CustomInstaller : Installer
public CustomInstaller()

public override void Commit(System.Collections.IDictionary savedState)
// Call the Commit method of the base class

// Open the registry key containing the path to the Application Manager
Microsoft.Win32.RegistryKey key = null;
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\microsoft\windows\currentversion\app paths\ceappmgr.exe");

// If the key is not null, then ActiveSync is installed on the user's desktop computer
if (key != null)
// Get the path to the Application Manager from the registry value
string appPath = null;
appPath = key.GetValue(null).ToString();

// Get the target directory where the .ini file is installed.
// This is sent from the Setup application
string strIniFilePath = """ + Context.Parameters["TargetDir"] + "ObScan.ini"";
if (appPath != null)
// Now launch the Application Manager
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = appPath;
process.StartInfo.Arguments = strIniFilePath;
throw new Exception("No Active sync installed");

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.