none
Using Visual Studio Deployment Projects to install standard windows shortcuts instead of advertised shortcuts

    Question

  • I have found many questions in various MSDN forums posted by people who are having problems with the shortcuts that are installed in the Start>Programs menu. These problems boil down to the use of advertised shortcuts by windows installer as a default.

    An example question is (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=155266&SiteId=1):

    Shortcut problems 
     
     I created a VS 2003 deployment project and I've set it up the way I want, even with a custom installer class.  At first I had shortcuts on the desktop and in the program files that were working.  Now, the shortcuts will uninstall the program if you double click them.  When looking at where they are pointed, they show the installation folder and not the executable.  I've recreated the shorcuts and changed other things, but nothing helps.  Does anyone have any ideas?

    In a different thread a Microsoft Employee (or I should say someone claiming to be) says that it is impossible to do in Visual Studio. He recommends using the ORCA database editor to modify the .msi file after the deployment project is built. He also gives a work-around that requires the developer to know the exact install path.

    However, I have discovered a way to override the use of advertised shortcuts from within Visual Studio. In short you have to trick Visual Studio into allowing a custom entry in the .MSI property table.

    Here is how I did it:

    1. Open the User Interface for your Deployment project (with the deployment project active choose View>Editors>User Interface).
    2. Select the "Start" section of the User Interface and then from the action menu choose "Add Dialog" and add a "Textboxes" dialog.
    3. In the properties pain for the Textboxes dialog set the BannerBitmap, BannerText, and BodyText properties to something informative to the user running the install (the user will never know that this dialog is doing something behind the scenes).
    4. Set the following properties for the Textboxes dialog:
      • Edit1Property: DISABLEADVTSHORTCUTS
      • Edit1Value: 1
      • Edit1Visible: false
      • Edit2Visible: false
      • Edit3Visible: false
      • Edit4Visible: false

    That’s it. When windows installer gets to that dialog and the user clicks "Next" it will insert the property DISABLEADVTSHORTCUTS = 1 into the property table and so when the actual install occurs standard windows shortcuts will be used instead of advertised shortcuts.

    Note: Due to the advantages of advertised shortcuts I recommend using the default setting if it will work in your situation. Only use this work-around if you have some reason to need standard shortcuts.

    Jacob Wagner
    Sr. IT Technician
    American River College
    wagnerjp AT arc DOT losrios DOT edu

     

    Tuesday, February 13, 2007 3:53 AM

All replies

  • Maybe I dont completely understand the difference between advertised shortcuts and regular shortcuts, but you could override the install event and then just create your own shortcut yourself in code. I did that and you can make it point wherever you want then just delete it yourself. I just got sick of trying to figure out how the installer did it. Not sure if this helps at all but i tried. You can then remove it on like commit event or something.

    [code]
    private void CreateShellLink(string shortcut,string target)
            {
                WshShell ashell = new WshShell();
                IWshShortcut ashortcut = (IWshShortcut)ashell.CreateShortcut(shortcut);
                ashortcut.TargetPath = target;
                ashortcut.WindowStyle = 1;
                ashortcut.Description = "sqlexpress";
                ashortcut.Save();
            }

    [/code]
    Tuesday, February 13, 2007 8:14 PM
  • The other thing here is that DISABLEADVTSHORTCUTS is just a Windows Installer property, and you can set it in any of the ways a property can be set. Adding it to the MSI file with Orca isn't wrong, just convenient. Setting it in the UI sequence in the exact same way that TARGETDIR is set isn't wrong either, although it migh be inconvenient to the end user. Or set it with msiexec /i <msi file> DISABLEADVTSHORTCUTS=1. Heck, you can even use a MSI tool that lets you specify it in the IDE, it's just Visual Studio that doesn't.

    Tuesday, February 13, 2007 9:12 PM
    Moderator
  • Hi there

    I'm including the DISABLEADVTSHORTCUTS in my setup project using a post-build event that calls a VBScript routine, but the shortcut I defined in the VS2005 editor is still being created the same, calling the MSI installer as soon as a DLL has been removed. I double-checked my MSI file with ORCA, and the property is there with a value of 1. Am I missing something?

    Cheers,
    Philipp
    Monday, March 05, 2007 1:01 PM
  • Make sure you've spelt it right - it must be upper case. If the shortcut has the target grayed out then it's still an advertised shortcut and the property is not set properly.
    Monday, March 05, 2007 2:46 PM
    Moderator
  • Phil,

    Thanks for the fast reply! I've noticed quite a few post of your's while doing lookups on the topic - you're doing a great job here

    The mistake was on my side - I just copied a script I found on Google Groups and checked visually with ORCA. The post can be found here, btw:

    http://tinyurl.com/2wj5xe

    The script, however, contains a mean bug - there is an invalid space at the end of the property name that is inserted into the MSI database. Fixed that one and it works like a charm now.

    Cheers,
    Philipp




    Monday, March 05, 2007 3:15 PM
  • This is the best solution I have seen by far!
    Sunday, March 27, 2011 12:08 PM