Create Setup Startmenu

Most users are used to start applications over the startmenu. If it is missing, most users will not be able to launch your software. This tutorial will first explain, what a startmenu-entry is exactly and then show you step by step, how to add a startmenu to your setup.

About startmenus

All entries you can see in the startmenu are shortcuts placed specific folders on your filesystem. Btw, the same applies for desktop-shortcuts!

User menuC:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Global menuC:\ProgramData\Microsoft\Windows\Start Menu\Programs
User desktopC:\Users\USERNAME\Desktop\
Global desktopC:\Users\Public\Desktop

Step By Step: Create a startmenu-entry

  1. Add the ProgramMenuFolder inside the TARGETDIR:
    <Fragment>
    	<Directory Id="TARGETDIR" Name="SourceDir">
    		<Directory Id="ProgramMenuFolder">
    			<Directory Id="ApplicationProgramsFolder" Name="My Wpf Application"/>
    		</Directory>
    		... 
    	</Directory>
    </Fragment>
    
  2. Add the new ProductMenuComponents-group, which holds the Shortcut we want to deploy, below the other ComponentGroups.
    <Fragment>
    	...
    	<ComponentGroup Id="ProductMenuComponents" Directory="ApplicationProgramsFolder">
    		<Component Id="ApplicationShortcut" Guid="{AE75A17D-3EBF-4B68-AA32-73D18D983317}" >
    			<Shortcut 
    				Id="ApplicationStartMenuShortcut" 
    				Name="My Wpf Application"
    				Description="My WPF Application - Any application description"
    				Target="[#FILE_MyWpfApplication.exe]"
    				WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
    			<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
    			<RegistryValue 
    				Root="HKCU" 
    				Key="Software\MyCompany\MyWpfApplication" 
    				Name="installed" Type="integer" Value="1" 
    				KeyPath="yes" />
    		</Component>
    	</ComponentGroup>
    </Fragment>
    

    Target: # is a pointer to a File-Id (<File Id="FILE_MyWpfApplication.exe" .. /> in the example), which is correctly replaced with the full path when installed.

  3. Set the Guid in the ApplicationShortcut-component.
  4. Adjust the name, description and the target.
  5. Add the new ComponentGroup to the features like this:
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
         xmlns:ui="http://schemas.microsoft.com/wix/UIExtension">
    	<Product ... />
    		...
    		<Feature Id="ProductFeature" Title="MyWpfApplicationSetup" Level="1">
    			...
    			<ComponentGroupRef Id="ProductMenuComponents" />
    		</Feature>
    	</Product>
    </Wix> 
    

You can now compile and run your setup. And start it over the startmenu!

What is RemoveFolder for?

RemoveFolder removes the complete startmenu-folder on uninstall – it’s that simple.

What is the RegistryValue for?

Windows-setup requires the KeyPath to detect a component. As the Shortcut does not have a KeyPath itself, the RegistryValue is used to provide one for the ApplicationShortcut-component.