I am developing an desktop based application using VB.NET, similar to add/remove program. Everything was working fine until i start working on uninstall feature. Now what am i doing is that i get the uninstall string of the specific application from the registry and use System.Diagnostics.Process to run UninstallString. Imports Microsoft.Win32 'Assists in Registry Reading & Writing. We need to add the arrays that will host our Uninstall commands: VB.NET. Private strUninstallStrings() As String 'Array to hold Uninstall commands for each program Private NewUninstallStrArr 'Filtered array containing ONLY valid uninstall commands. VB.NET using WMI to uninstall programs remotely Hey all, i'm currently working on a project for our IT group. What this program does is lists all the installed programs on the remote machine for the admin. What i'm trying to add is functionality for the admin to select a program from the list and click an uninstall button on the program to. Method 1: Uninstall Microsoft Visual Basic 6.0sp5 via Programs and Features. When a new piece of program is installed on your system, that program is added to the list in Programs and Features.
From the image below, I will explain to you what key and its data means. I will only explain the key's that are important to know.
Contact
:
Who to contact for support.Display Name
:
The name of the Software.Display Version
:
The version of the software.Estimated Size:
The size of the software. (You need to convert this to an Integer, so the User can understand it)Help Link
:
Link to visit for help.Help Telephone:
Help Telephone Number.Installed Date:
The date this Software was installed. Install Location:
The Installation Location.Install Source:
The Installation Directory.Language:
Languages supported by this Software.Local Package:
The MSI File Location.ModifyPath:
The string returned here looks something like this: MsiExec.exe /I{AC76BA86-7AD7-1033-7B44-A81200000003}I will explain this to you more in a section in this article.
Publisher:
The publisher of the Software.Readme:
The location of the readme file for this software.UninstallString:
The uninstallString returns a value similar to ModifyPath. I will explain more about this later on.URLInfoAbout:
The URL to visit for more information on the Product.URLUpdateInfo
:
The url to visit for updates information.Version:
Version of the Software.Product Uninstall: What the heck is MsiExec.exe /I{AC76BA86-7AD7-1033-7B44-A81200000003}?
That is what I said when I first saw this string. I did some research on this. And what really helped me out was the Microsoft TechNet Website. http://technet.microsoft.com/en-us/library/bb490936.aspx.
The following will teach you about the Syntax and other Parameters that you can use.
Uninstall Program Using Registry
Syntax
msiexec/f [p][o][e][d][c][a][u][m][s][v]{package|ProductCode}
Parameters
/f: Enables one or more of the command-line options listed in the following table.
Description | |
---|---|
p | Reinstalls only if file is missing. |
o | Reinstalls if file is missing or if an older version is installed. |
e | Reinstalls if file is missing or an equal or older version is installed. |
d | Reinstalls if file is missing or a different version is installed. |
c Qwel and maker the harvest rar. | Reinstalls if file is missing or the stored checksum does not match the calculated value. |
a | Forces all files to be reinstalled. |
u | Rewrite all required user-specific registry entries. |
m | Rewrites all required computer-specific registry entries. |
s | Overwrites all existing shortcuts. |
v | Runs from source and re-caches the local package. |
package: Name of the Windows Installer package file.
ProductCode: Globally unique identifier (GUID) of the Windows Installer package.
You can use msiexec and any of the commands shown above to perform the operation.
Uninstalling a Product.
Variables to Decalre:
String uninstallString
- String that will hold the UninstallString for the Product to UninstallProcess UninstallProcess
- Process that will run the Uninstallation.String temp
- Hold the part 2 of the UninstallString.
![Uninstall Program Using Vb.net Uninstall Program Using Vb.net](/uploads/1/2/4/7/124796958/395484913.png)
The 'UninstallProcess'....How it all works...
The split makes the filename MsiExec.exe. This will run the Microsoft Installer.
UninstallProcess.StartInfo.FileName = _ uninstallstring.Split('/'.ToCharArray)(0)
<code><code><code><code><code>
Argument temp will tell the uninstaller which product to uninstall, because temp holds the ProductCode.UninstallProcess.StartInfo.Arguments = temp
Run the Uninstaller
UninstallProcess.Start()
Listing all the Software Installed...
All Source Code:
Uninstalling a Software
Listing all Software into a Listview (lstPrograms):
Conclusion
This application is a great way for Developers to interact with the Windows API and the Registry. You also get to learn how some calls are made in the Windows Environment. I really hope to see Developers using techniques shown in this article in their Applications.
|