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
  • 34,719
  • 24
  • 185
  • 251
Tamil
  • 1,125
  • 1
  • 12
  • 34

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,602
  • 2
  • 20
  • 40
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,515
  • 11
  • 56
  • 88
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
  • 27,666
  • 13
  • 65
  • 102