none
.exe shortcut restores deleted files in application folder

    Question

  • Hi everyone,

     

     

    I have created a setup project for my application so that during the installation of this application, a shortcut is added to the user's desktop.  Standard stuff.  The user installs the program and away they go.

     

    When using the program, the user is given the ability to view information/data using a set of default views pre-installed with the program and saved under /Program Files/Application Folder/My Views.  The user can create/delete/modify views to suit their needs. 

     

    The problem is that if the user deletes some of the default views, these views seem to magically appear again when the program is re-run from the desktop shortcut.  As I mentioned earlier, this shortcut is created during the installation process.  When the user double clicks this shortcut, an installer window appears and replaces any missing files in the application folder.  Obviously this is a nice trick since legitimate missing program files can be replaced with out  user intervention.  Unfortunately, for my purposes, this works against me since each deleted view magically appears again once the user restarts the program from this desktop shortcut.

     

    The same affect is not seen if the user launches the program directly from the .exe file in the application folder or if the user creates a new shortcut and places it on the user desktop.  This issue only seems to occur when the shortcut created during the installation process is selected.

     

    As I stated above, obviously this is a nice feature to have and as such there must be some way to enable or disable this?  Sorry for the probably very easy question but I can't for the life of me find a quick and easy solution to this.

     

    Thanks for your time,

    Olimess

     

     

    Friday, August 24, 2007 3:33 PM

Answers

  •  

    Thanks Phil.

     

    You pointed me in the right direction.  Turns out that the shortcut installed to the desktop during installation is a special kind of shortcut created by the Visual Studio/Installer called an advertised shortcut.  This type of shortcut checks the installer to see if the program needs to be installed or repaired prior to launching the shortcut.  Disabling this option to have a regular, non-advertised, shortcut can not be done directly with Visual Studio but it can be done.

     

    These are the two methods I dug up.

     

    Method 1 (Manual Approach):

    Download and install the Windows Installer SDK.  From this you will be able to obtain a program called orca.msi.  Install and run ORCA and open your MSI file created by Visual Studio for your app.  In Orca, select the property table.  Add a new row to the Property table with the following values for the columns:

     

    Property: DISABLEADVTSHORTCUTS

    Value: 1

     

    Save your MSI.  Now when you install your program using your modified application MSI, the program shortcuts created will all be regular, non-advertised, shortcuts.

     

     

    Method 2 (Automatic Approach - Recommended):

    Again, through the installation of the Windows Installer SDK you can obtain a file called WiRunSQL.vbs.  Copy this file into your project directory.  Now, in Visual Studio 2005, select your setup project in the solution explorer.  Select its properties.  In the property window, add the following script to PostBuildEvent property.

     

    cscript //nologo "$(ProjectDir)WiRunSql.vbs" "$(BuiltOuputPath)" "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"

     

    This script will automatically run once the project has been built and will insert the DISABLEADVTSHORTCUTS true value into the application MSI property table.  Basically the script does the same thing that we did using method 1.  Now when you install your program using the application MSI, the program shortcuts created will all be regular, non-advertised, shortcuts.

     

     

    Hope that helps someone out there facing the same issue.  Thanks again Phil for your time and help.

     

     


    Friday, August 24, 2007 8:18 PM

All replies

  • There is no quick and easy solution because repair is an integral part of Windows Installer.

     

    1) Search on DISABLEADVTSHORTCUTS. This will turn off shortcut repair, but that doesn't mean there'll never be a repair. Right click the MSI file and choose repair or from Add/Remove Programs will restore missing files.

    2) This thread http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1955717 

     

    Friday, August 24, 2007 4:35 PM
    Moderator
  •  

    Thanks Phil.

     

    You pointed me in the right direction.  Turns out that the shortcut installed to the desktop during installation is a special kind of shortcut created by the Visual Studio/Installer called an advertised shortcut.  This type of shortcut checks the installer to see if the program needs to be installed or repaired prior to launching the shortcut.  Disabling this option to have a regular, non-advertised, shortcut can not be done directly with Visual Studio but it can be done.

     

    These are the two methods I dug up.

     

    Method 1 (Manual Approach):

    Download and install the Windows Installer SDK.  From this you will be able to obtain a program called orca.msi.  Install and run ORCA and open your MSI file created by Visual Studio for your app.  In Orca, select the property table.  Add a new row to the Property table with the following values for the columns:

     

    Property: DISABLEADVTSHORTCUTS

    Value: 1

     

    Save your MSI.  Now when you install your program using your modified application MSI, the program shortcuts created will all be regular, non-advertised, shortcuts.

     

     

    Method 2 (Automatic Approach - Recommended):

    Again, through the installation of the Windows Installer SDK you can obtain a file called WiRunSQL.vbs.  Copy this file into your project directory.  Now, in Visual Studio 2005, select your setup project in the solution explorer.  Select its properties.  In the property window, add the following script to PostBuildEvent property.

     

    cscript //nologo "$(ProjectDir)WiRunSql.vbs" "$(BuiltOuputPath)" "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"

     

    This script will automatically run once the project has been built and will insert the DISABLEADVTSHORTCUTS true value into the application MSI property table.  Basically the script does the same thing that we did using method 1.  Now when you install your program using the application MSI, the program shortcuts created will all be regular, non-advertised, shortcuts.

     

     

    Hope that helps someone out there facing the same issue.  Thanks again Phil for your time and help.

     

     


    Friday, August 24, 2007 8:18 PM
  • Note that the only thing that absolutely guarantees any kind of repair ever on a file is clearing the Component guid:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1955717 

    DISABLEADVTSHORTCUTS does not stop manual repair or repair initiated by non-shortcut methods (it's not just shortcuts that can start a repair).

     

    Friday, August 24, 2007 10:18 PM
    Moderator
  • Yes, this solution can solve the problem.But this issue still appear:

     If the user click on a file which type is associated with the Exe file.

     

    Can you please let me know how to resolve this issue? Is there another property setting like as "DISABLEADVTSHORTCUTS"?

     

    Thanks in advance,

    Armthin.

    Thursday, September 06, 2007 6:03 AM
  • I know this post is old but THANK YOU!

    This has been a thorn in my side for awhile. I ended up using a shell script to create shortcuts manually via a DLL getting called as a custom action in the MSI, this is much more elegant.

     


    -Chris
    Thursday, September 23, 2010 9:39 PM