Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a demo Wix installer. I'm trying to add shortcuts. The Desktop shortcut and Uninstall shortcut on the Start Menu both appear, but the Start shortcut on the Start Menu does not.

Shouldn't the Uninstall shortcut the Start shortcut both appear in the same folder on the Start Menu?

Here's my code:
<Directory Id="DesktopFolder"/>
<Directory Id="StartMenuFolder"/>

<Component Id="ApplicationShortcuts" 
			Guid="{EAF36C1C-255A-44D0-890C-8DFCE8671F3D}" 
			Directory="ApplicationProgramsFolder">
			
	<!--The Desktop shortcut-->
	<Shortcut Id="wixDemoDesktop" 
				Directory="DesktopFolder" 
				Name="!(bind.property.ProductName)"
				WorkingDirectory='MAINFOLDER' 
				Advertise="no" />

	<!--The Start Menu shortcut DOES NOT APPEAR!!-->
	<Shortcut Id="ApplicationShortcut" 
				Name="Start !(bind.property.ProductName)" 
				Description="Start !(bind.property.ProductName)" 
				WorkingDirectory="MAINFOLDER"
				Directory="StartMenuFolder"
				Advertise="no"/>
				
	<!--The uninstall shortcut on the start menu-->
	<Shortcut Id="UninstallShortcut" 
				Name="Uninstall !(bind.property.ProductName)" 
				Description="Uninstall !(bind.property.ProductName)" 
				Target="[System64Folder]msiexec.exe" 
				Arguments="/x [ProductCode]"/>
			
	<RegistryValue Root="HKCU" 
					Key="Software\!(bind.property.Manufacturer)\!(bind.property.ProductName)" 
					Name="!(bind.property.ProductName) Shortcut" 
					Type="integer" 
					Value="1" 
					KeyPath="yes"/>
			  
	<RemoveFolder Id="ApplicationProgramsFolder" 
					On="uninstall"/>
		  
</Component>			


What I have tried:

Google examples and the Wix documentation
Posted
Updated 21-Jan-23 4:42am
Comments
Patrice T 18-Jan-23 1:20am    
Why you don't ask Wix ?
They have support service
[no name] 18-Jan-23 9:54am    
It appears that the issue you are facing is that the Start Menu shortcut is not appearing as expected. Here are a few things to check:

Make sure that the "Directory" attribute of the "Shortcut" element is set to "StartMenuFolder" as in your code snippet,

Make sure that the "Name" attribute is set to "Start !(bind.property.ProductName)" as in your code snippet.

Make sure that the "WorkingDirectory" attribute is set to "MAINFOLDER" as in your code snippet.

Make sure that the "Advertise" attribute is set to "no" as in your code snippet.

Make sure that the Shortcut Id attribute is unique and doesn't conflict with any other shortcut id in the installer

Check the log files of the installer, if there is any error or warning related to the shortcut, it might give you an idea of what's going wrong.

Make sure that the component containing the shortcut is included in the feature that is installed.

If none of the above suggestions work, please consider sharing the log files of the installer and the exact version of Wix Toolset you're using.

1 solution

I will post this here as the solution as this member have left our forum, I hope these checks help you resolve the error -

It appears that the issue you are facing is that the Start Menu shortcut is not appearing as expected. Here are a few things to check:

Make sure that the "Directory" attribute of the "Shortcut" element is set to "StartMenuFolder" as in your code snippet,

Make sure that the "Name" attribute is set to "Start !(bind.property.ProductName)" as in your code snippet.

Make sure that the "WorkingDirectory" attribute is set to "MAINFOLDER" as in your code snippet.

Make sure that the "Advertise" attribute is set to "no" as in your code snippet.

Make sure that the Shortcut Id attribute is unique and doesn't conflict with any other shortcut id in the installer

Check the log files of the installer, if there is any error or warning related to the shortcut, it might give you an idea of what's going wrong.

Make sure that the component containing the shortcut is included in the feature that is installed.

If none of the above suggestions work, please consider sharing the log files of the installer and the exact version of Wix Toolset you're using.


I think I might be off-topic with the following, if so, my apologies. In C#, you can create application shortcuts using the ShellLink class from the Microsoft.WindowsAPICodePack.Shell namespace. Here is an example of how you can create a shortcut to a specific file on the desktop:

using Microsoft.WindowsAPICodePack.Shell;

class Program {
    static void Main() {
        var shortcut = (IShellLinkW) new ShellLink();
        shortcut.SetDescription("My shortcut description");
        shortcut.SetPath("C:\\path\\to\\myfile.exe");
        shortcut.SetArguments("");
        shortcut.SetWorkingDirectory("C:\\path\\to");

        var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
        var shortcutPath = System.IO.Path.Combine(desktopPath, "My Shortcut.lnk");
        shortcut.Save(shortcutPath);
    }
}


This will create a shortcut to the file myfile.exe on the user's desktop, with the description "My shortcut description".

You can also set the icon of the shortcut using the SetIconLocation() method of the IShellLinkW interface and you can set the working directory using SetWorkingDirectory() method of the IShellLinkW interface

shortcut.SetIconLocation("C:\\path\\to\\myicon.ico", 0);
shortcut.SetWorkingDirectory("C:\\path\\to");


Note that you will need to add a reference to the Microsoft.WindowsAPICodePack.Shell assembly in your project in order to use the ShellLink class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900