1

Earlier we released an application <application name>. Later a new version of the application was released but with different application name <company name> <application name>. But both these applications put files in the same program folder. But we have two different versions listed in uninstall programs.

Now that we want to release a newer version. An we want to uninstall the very first version from the user's pc. how can I achieve this using c#. We are using windows 7 64 bit (application is 32 bit and installed in x86 folder).

I don't have the application setup neither the application key

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tamil
  • 1,173
  • 1
  • 13
  • 35

3 Answers3

1

If you have an installer project you can specify this in the installer properties.

See: VS2008 Setup Project: Uninstalling the previous MSI

Community
  • 1
  • 1
thekip
  • 3,660
  • 2
  • 21
  • 41
1

If you're application cannot detect it's early version (Different Name) ,than you probably should delete Data from Places where these 2 Application interferes . You could do that with File.Delete(); but if these Files are somewhere where Application has not permission's you should force it run as Admin by Adding a Manifest File and replace that line.

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Rosmarine Popcorn
  • 10,761
  • 11
  • 59
  • 89
0

Have a look at the COM WindowsInstaller classes. You will need to add a reference to the WindowsInstaller class to get access to it. From here you can browse the MSI and perform actions on it if required. I use this in my post build to modify the archive to fix a... undocumented functionality of Visual Studio.

// Create an Installer instance   
MsiInstaller = Activator.CreateInstance(Type.GetTypeFromProgID("WindowsInstaller.Installer")) as WindowsInstaller.Installer;
// Open the msi file for Read/Write   
MsiDatabase = MsiInstaller.OpenDatabase(MsiFile.FullName, MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);
Spence
  • 28,526
  • 15
  • 68
  • 103