How to make running application to uninstall itself?

Today I had this requirement. The application that running in windows mobile has to uninstall itself. So started thinking in this lines.

Will windows mobile allow me to uninstall a running application? Even if it does can the application uninstall itself.  After spending 20 - 30 mins in MSDN, I found out that uninstall CSP can do this job. Once the request is submitted to the Configuration manager, it does what you want. Below is the function that I have written to cater this requirement.

private void UninstallThis()
{
 XmlDocument xmlDoc = new XmlDocument();
 StringBuilder sb = new StringBuilder();
 sb.Append("<wap-provisioningdoc> ");
 sb.Append("<characteristic type=\"UnInstall\">");
 sb.Append("<characteristic type=\"Sample Application\">");
 sb.Append("<parm name=\"uninstall\" value=\"1\"/>");
 sb.Append("</characteristic>");
 sb.Append("</characteristic>");
 sb.Append("</wap-provisioningdoc>");
 xmlDoc.LoadXml(sb.ToString());
 ConfigurationManager.ProcessConfiguration(xmlDoc, false);
}

Comments

  • Anonymous
    June 13, 2007
    Raja, it’s good to see your Blog. Let me proudly say “Great Buddy”. You could write tips, comparative details on other mobile Technology, code snippets, bits and pieces and your lesson learnt for the new comers here on WindowsMobile and ME. Thanks.