Hello there! Since it's the first time I post in this blog, allow me to introduce myself. My name is Jin Zhang and I've been the tester for Application Management for the past year. If you are wondering what Application Management is, it consists of wceload (and related binaries), cabwiz and cabsigntool.
This might be an old topic but doing a quick search online I noticed this question is still being asked. There are several ways to uninstall your application programmatically but perhaps the simplest way to do it is using the Uninstall Configuration Service Provider (CSP). Being able to programmatically do things is always a good thing, but for uninstalling programmatically, perhaps the most common use case would be the ability to remove a program without any user-intervention.
Essentially, you need to "push" an XML file that the Uninstall CSP will process. Provisioning an XML file can be achieved in different ways but for this post I'll go over the API DMProcessConfigXML.
In native code all you need to do is include "cfgmgrapi.h" and call the function: DMProcessConfigXML(LPCWSTR pszWXMLin, DWORD dwFlags, LPWSTR* ppszwXMLout)
In managed code, a managed wrapper is provided by the object ConfigurationManager found in the namespace Microsoft.WindowsMobile.Configuration: public static XmlDocument ProcessConfiguration ( XmlDocument configDoc, bool metadata)
As for the actual XML string, take the following but replace "Your App" with the name of your application:
<wap-provisioningdoc> <characteristic type="UnInstall"> <characteristic type="Your App"> <parm name="uninstall" value="1" /> </characteristic> </characteristic></wap-provisioningdoc>
The code above will trigger the uninstall of your application without any prompting. Keep in mind that if your application contains a setup.dll and your Uninstall_Init function displays UI, this might defeat the purpose of a silent uninstall. Of course, you can design your setup.dll in such a way that will not prompt during a programmatically initiated uninstall.
I hope the above will help some of you. If you are burning to know about a specific topic regarding Application Management, leave your comments below and if there is enough interest, I'll consider it as a future topic.