Windows > Windows Forms Forums > ClickOnce and Setup & Deployment Projects > File that is no longer marked permanent is not getting uninstalled
Ask a questionAsk a question
 

AnswerFile that is no longer marked permanent is not getting uninstalled

  • Friday, November 06, 2009 9:11 PMKaren Ahmad Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Previous builds of our setup and deployment project contained a file that was marked as permanent.  We no longer want this file to be permanently installed.  So I set the Permanent property of the file to False.  If I do the following

    Install old version (File is marked permanent)
    Install new version (File is NOT marked permanent)
    Uninstall program

    then the file is still installed on the user's machine.  This leaves me with the following two questions.

    1.  Shouldn't the file be uninstalled since it is not marked permanent?
    2.  If this is the proper behavior then how do I ensure that the file is removed during the uninstall?

    Thank you for your help -
    Karen Ahmad

Answers

  • Friday, November 06, 2009 10:59 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Unfortunately for you, no it shouldn't be uninstalled because that's what Permanent means. It's not a project setting that you can turn on and off. It means that when that file was installed to the system marked Permanent then that file is on the system permanently.  You can't have it work both ways - you can't have the file permanently on the system and then say you want to uninstall it.  There really is no way to remove it. Somewhere on the system there's an installer component reference count for that file that will always be greater than zero.  I'm not sure what you can do in this situation.
    Phil Wilson
  • Monday, November 09, 2009 7:38 AMKira QianMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Karen,

    PhilWilson’s answer is just what I want to say. If you want to install the new version, you need to uninstall the old one and delete that permanent file manually.

    If you have any other question, please feel free to tell me.

    Sincerely,
    Kira Qian
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked As Answer byKaren Ahmad Friday, November 13, 2009 12:22 AM
    •  
  • Friday, November 13, 2009 12:19 AMKaren Ahmad Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Thank you to everyone who provided feedback.  It was very helpful.

    Windows Installer is not able to uninstall files that were marked permanent in a previous installation of the program.  This means the file will exist on the user's machine when the new version of the program is installed.  The Windows Installer file versioning rules state that non-versioned files will only be replaced if the create date = modified date.  Currently, the program does not modify the file.  However, there is nothing stopping a curious user from modifying the file.  Therefore, I needed a way to ensure that the previous version of the file was removed before the new version of the file was installed.

    My solution was to do the following in the PostBuildEvent of the setup and deployment project.

    * Resequence the RemoveExistingProducts action in the InstallExecuteSequence table between the InstallInitialize action and the AllocateRegistrySpace action.  I was already doing this so the previous version would be uninstalled before the new version was installed.  Then I wouldn't have to worry about files not being replaced due to the Windows Installer file replacement rules.

    * Add a record to the RemoveFile table
         FileKey = 72 character unique value that follows the rules of the Windows Installer Identifier data type
         Component = Lookup file in File table and get the value in the Component field
         FileName = ShortFileName|LongFileName as it exists in the File table
         DirProperty = Lookup Component in Component table and get the value in the Directory_ field
         InstallMode = 1 (Remove file on install)

    * Verify that Sequence of RemoveFiles action in InstallExecuteSequence table is less than Sequence of InstallFiles action in InstallExecuteSequence table

    • Marked As Answer byKaren Ahmad Friday, November 13, 2009 12:22 AM
    •  

All Replies

  • Friday, November 06, 2009 9:43 PMColbyRingeisen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    If your clickonce install is launching an MSI installation...

    1. If the newer MSI version is a major upgrade, then no.  Uninstall is handled by the cached MSI database already on the system (the cached MSI database for the earlier version).  Since the file is marked permanent in that database the uninstall of that database (initiated by the intall of the major upgrade) leaves the file behind.
    2. Add records to the AppSearch and CompLocator tables that set an MSI property to the folder path of the component in question.  Then add a record to the RemoveFile table that removes the file when the new install runs.
  • Friday, November 06, 2009 10:59 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Unfortunately for you, no it shouldn't be uninstalled because that's what Permanent means. It's not a project setting that you can turn on and off. It means that when that file was installed to the system marked Permanent then that file is on the system permanently.  You can't have it work both ways - you can't have the file permanently on the system and then say you want to uninstall it.  There really is no way to remove it. Somewhere on the system there's an installer component reference count for that file that will always be greater than zero.  I'm not sure what you can do in this situation.
    Phil Wilson
  • Monday, November 09, 2009 7:38 AMKira QianMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Karen,

    PhilWilson’s answer is just what I want to say. If you want to install the new version, you need to uninstall the old one and delete that permanent file manually.

    If you have any other question, please feel free to tell me.

    Sincerely,
    Kira Qian
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked As Answer byKaren Ahmad Friday, November 13, 2009 12:22 AM
    •  
  • Friday, November 13, 2009 12:19 AMKaren Ahmad Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Thank you to everyone who provided feedback.  It was very helpful.

    Windows Installer is not able to uninstall files that were marked permanent in a previous installation of the program.  This means the file will exist on the user's machine when the new version of the program is installed.  The Windows Installer file versioning rules state that non-versioned files will only be replaced if the create date = modified date.  Currently, the program does not modify the file.  However, there is nothing stopping a curious user from modifying the file.  Therefore, I needed a way to ensure that the previous version of the file was removed before the new version of the file was installed.

    My solution was to do the following in the PostBuildEvent of the setup and deployment project.

    * Resequence the RemoveExistingProducts action in the InstallExecuteSequence table between the InstallInitialize action and the AllocateRegistrySpace action.  I was already doing this so the previous version would be uninstalled before the new version was installed.  Then I wouldn't have to worry about files not being replaced due to the Windows Installer file replacement rules.

    * Add a record to the RemoveFile table
         FileKey = 72 character unique value that follows the rules of the Windows Installer Identifier data type
         Component = Lookup file in File table and get the value in the Component field
         FileName = ShortFileName|LongFileName as it exists in the File table
         DirProperty = Lookup Component in Component table and get the value in the Directory_ field
         InstallMode = 1 (Remove file on install)

    * Verify that Sequence of RemoveFiles action in InstallExecuteSequence table is less than Sequence of InstallFiles action in InstallExecuteSequence table

    • Marked As Answer byKaren Ahmad Friday, November 13, 2009 12:22 AM
    •