Use Wix installer to add shortcut to subfolder in startmenu programs

Seth picture Seth · Jan 5, 2010 · Viewed 9.2k times · Source

I am trying to add my program shortcut to an existing folder in the start menu shortcuts. For example All Programs -> AppNameFolder -> AppNameVersionFolder -> AppShortcut

In order to achieve this I added the extra lines:

          <Directory Id="ProgramMenuFolderApp" Name="App">
                <Directory Id="ProgramMenuDir" Name="APP 6.3.0">

to the following code in my .wxs file:

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder" Name="Program Files">
            <Directory Id="CompanyName" Name="CompanyName">
                <Directory Id="App" Name="App">
                    <Directory Id="INSTALLDIR" Name="App 6.3.0">
                        <Component Id="MainExecutable" Guid="23FFE6FD-2BEA-4946-9875-8DBEEA5AAF55">
                            <File Id="AppEXE" Name="App.exe" Source="App.exe" KeyPath="yes">
                                <Shortcut Id="startmenu" Directory="ProgramMenuDir" Name="App 6.3.0" WorkingDirectory='INSTALLDIR' Icon="App.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopApp" Directory="DesktopFolder" Name="App 6.3.0" WorkingDirectory='INSTALLDIR' Icon="App.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
        </Directory>
        <Directory Id="ProgramMenuFolder" Name="Programs">
            <Directory Id="ProgramMenuFolderApp" Name="App">
                <Directory Id="ProgramMenuDir" Name="App6.3.0">
                    <Component Id="ProgramMenuDir" Guid="BF266F76-192A-493E-B5C7-C54660E61D7D">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKCU" Key="Software\CompanyName\App6.3.0" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>            
        </Directory>
        <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>

I get the following error when I try and build:

The directory ProgramMenuFolderApp is in the user profile but is not listed in the RemoveFile table.

However, I do not want to remove the higher level folders when I uninstall, I only want to remove the App 6.3.0 folder and below.

How can I add the shortcut to a program subfolder in the start menu?

Answer

Rob Mensching picture Rob Mensching · Jan 5, 2010

If that message is coming from ICE64 then it is a warning. ICE warnings should be understood and if acceptable ignored. http://msdn.microsoft.com/en-us/library/aa369011(VS.85).aspx has this to say:

ICE64 checks that new directories in the user profile are removed correctly in roaming scenarios.

Failure to fix a warning or error reported by ICE64 generally leads to problems in completely cleaning the computer during an uninstallation. When a roaming user who has installed the application logs on to a computer for the first time, all of the profile is copied down onto the computer. On advertisement (which takes place after the roaming profile download), the Installer verifies that the directory is already there and therefore does not delete it on uninstallation. This leaves the directory on the user's computer permanently.

It isn't clear why you would want to leave an empty "App" dir in the Start Menu. Seems like addressing the ICE issue is easiest. To do so, just add another RemoveFolder element to your ProgramMenuDir Component.