In visual studio 2010 while creating setup package when you select RemovePreviousVersions = true

even then the old application installed is not removed  in order to fix that

save the below vbs code in project directory


Dim objInstaller
 Dim objDatabase
 Dim objView
 Dim objResult

Dim strPathMsi

If WScript.Arguments.Count <> 1 Then
 WScript.Echo "Usage: cscript fixRemovePreviousVersions.vbs "
 WScript.Quit -1
 End If

strPathMsi = WScript.Arguments(0)

Set objInstaller = CreateObject("WindowsInstaller.Installer")
 Set objDatabase = objInstaller.OpenDatabase(strPathMsi, 1)
 Set objView = objDatabase.OpenView("UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'")

WScript.Echo "Patching install sequence: UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'"
 objView.Execute
 objDatabase.Commit

WScript.Quit 0

save the file with name  fixRemovePreviousVersions.vbs

now in vs 2010 set PostBuildEvent  to  cscript “$(ProjectDir)fixRemovePreviousVersions.vbs $(BuiltOuputPath)”

PostBuildEvent  can be found in setup project properties

Now build you msi and it will patch the msi and now the previous installed version will be removed.