Use Wix installer to add shortcut to subfolder in startmenu programs
Asked Answered
R

1

9

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?

Reface answered 5/1, 2010 at 4:50 Comment(0)
M
9

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.

Malemute answered 5/1, 2010 at 6:46 Comment(5)
Great! I didn't realise that even though the linking with light.exe was showing an error it was still creating an MSI. The "App" dir will not be empty, it will have other folders for the same application but different versions.Reface
I just added <RemoveFolder Id="ProgramMenuFolderApp" On="uninstall" /> to the ProgramMenuDir component and I am still getting the error.Reface
@Seth, So you still got the error after adding RemoveFolder to the ProgramMenuDir component, huh? I think RemoveFolder should be inside the directory it's removing, not on the same level as it. Also, did you add a RegistryValue for the second RemoveFolder?Probity
I figured I'd add some helpful info to this old question, the likely problem with Seth's entry is that he set the Id, but not the Directory. The component it was under likely had a different directory and the RemoveFolder was picking this up. If you specify the Directory attribute, the warning goes away.Countermark
In addition to the comment by @Countermark it is worth noting that RemoveFolder will only delete the folder if it is empty after uninstallation. So if you have other applications sharing the same folder structure it won't remove them.Mistrot

© 2022 - 2024 — McMap. All rights reserved.