Wix:How Can I Create Shortcut Without Registry - wix

In our project, we are going to remove registry entries to make non-admin users able to install it.
Our current code is as follow, I tried to comment out the section from the XML file but failed.
Is there any chance that we can create the shotcut without registry key? thanks.
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="C85221B1-70CA-455D-B322-093543BD4DF0">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="$(var.ProductName)"
Description="$(var.ProductDescription)"
Target="[APPLICATIONROOTDIRECTORY]OMOffline.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY" />
<Shortcut Id="RemoteAssistance"
Name="Request Remote Assistance"
Description="Starts Remote Assistance and creates a password-protected RA ticket that is attached to a new Remote Assistance invitation. The User must enter the e-mail address of the Helper in the To field to send the message to the Helper."
Target="[SystemFolder]MSRA.exe"
Arguments="/email"/>
<Shortcut Id="UninstallProduct"
Name="Uninstall $(var.ProductName)"
Target="[SystemFolder]msiexec.exe"
Arguments="/x [ProductCode] SQLSERVER="[SQLSERVER]""
Description="Uninstalls $(var.ProductName)" />
<RemoveFolder Id="RemoveApplicationProgramsFolder"
Directory="ApplicationProgramsFolder"
On="uninstall"/>
<!--<RegistryValue Root="HKCU" Key="Software\$(var.ProductManufacturer)\$(var.ProductName)" Name="shortcutsinstalled" Type="integer" Value="1" KeyPath="yes"/>-->
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="C03900DF-FFD8-44B8-AA42-1BC72BB9E1F4">
<Shortcut Id="ApplicationDesktopShortcut"
Name="$(var.ProductName)"
Description="$(var.ProductDescription)"
Target="[APPLICATIONROOTDIRECTORY]OMOffline.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY" />
<!--<RegistryValue Root="HKCU" Key="Software\$(var.ProductManufacturer)\$(var.ProductName)" Name="desktopshortcutinstalled" Type="integer" Value="1" KeyPath="yes"/>-->
</Component>
</DirectoryRef>

HKCU is per-User entry, That should not Interfere with your goal of Making per-user Install. You can use http://blogs.msdn.com/b/rflaming/archive/2006/09/30/778690.aspx to make a package per-user Installable.
To answer your question, I tried installation without registryvalue. Program Was allowed to build (with ICE38/ICE41 error), I was able to see the link post Installation of MSI

Related

WiX Shortcuts Not Detecting Files In Application Directory

Part of my application needs to read a config file, which I keep in the same directory as my application's exe. My issue is that the shortcuts created by WiX don't find this file.
I can create my shortcuts post install, and they work, but I would rather fix this issue instead of doing that.
This is what my component looks like:
<Component Id="MyApp.exe" Guid="G-U-I-D">
<File Id="MyApp.exe" Name="MyApp.exe" Source="$(var.MyApp_TargetDir)MyApp.exe">
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="My Application" Icon="Icon.ico" Advertise="yes" />
<Shortcut Id="StartMenuShortcut" Directory="ProgramMenuFolder" Name="My App" Icon="Icon.ico" Advertise="yes" />
</File>
</Component>
UPDATE: If I understand your comment correctly, I am wondering if you simply do not set the shortcut's WorkingDirectory attribute?
WiX Markup Sample:
<Directory Id="MyDir" Name="My Dir">
<Component Id="My.exe" Feature="Main">
<File Source="My.exe">
<Shortcut Id="DesktopShortcut"
Directory="DesktopFolder"
Name="My Product"
Advertise="yes"
WorkingDirectory="MyDir">
</Shortcut>
</File>
</Component>
</Directory>
Shortcut Properties:
If this is a settings file that you intend to write to you should put it in the user profile so that it is writeable for the launching user. Your application.exe file should be able to find the config file regardless if it is in your application installation folder or in the user profile?
C# mockup (should use Path.Combine, but this is just for illustration):
string filepath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + #"\MyFolder\MyFile.xml";
Is there a specific need to specify the file path in the shortcuts?
Some Links:
Various ways to deal with config files and writeability.

WiX Installer removes shortcut on upgrade

I am using the WiX Toolkit v3.11 for creating setups of my software. During installation I create startmenu shortcuts with the following code:
<Shortcut Id='startmenuMyProgram'
Name='$(var.MyProgramName)'
Directory='ProgramMenuFolder'
WorkingDirectory='APPLICATIONFOLDER'
Advertise='yes'
Icon='icon.exe'>
<Icon Id='icon.exe' SourceFile='$(var.Setuppath)\MyProgram.exe'/>
</Shortcut>
In this way I also create two shortcuts for other executables. Now for the uninstall I want to remove the shortcuts.
<Component Id="removeStartmenuShortcuts" Guid="803ad14a-feab-4901-b9db-2c4a1298ae8b">
<Condition>(REMOVE=ALL) AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)</Condition>
<RemoveFile Id="remove_startmenuProgram1" Name="startmenuMyProgram" On="uninstall" />
<RemoveFile Id="remove_startmenuProgram2" Name="startmenuMyProgram2" On="uninstall"/>
<RemoveFile Id="remove_startmenuProgram3" Name="startmenuMyProgram3" On="uninstall"/>
</Component>
This works without any problems when I uninstall the software. But the shortcuts are also removed when an update is performed. But I want to prevent this behavior, but the condition seems not to work. So all shortcuts like in the Windows task bar are removed when I do an update.
How can I make my update progress work correctly?
Here the behavior after update:
The group with all shortcuts in the right is missing!
You can combine the 2 component. By this you will not need to use condition statements.
The registry value is to set a keypath under component.
<Component Id="cmpstartmenuMyProgram" Guid="{67CB4F7A-5028-4697-A47F-DE99110B9645}">
<Shortcut Id="Shortcut.ApplicationName"
Name="ApplicationName"
Target="[INSTALLDIR]ApplicationName.exe"
WorkingDirectory="INSTALLDIR"
Directory="StartMenuFolder"
Icon="Icon.exe"/>
<RemoveFile Id="RemoveStartMenuShortcut.ApplicationName" Name="ApplicationName" Directory="StartMenuFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Compony\ComponyName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>

Wix shortcut desktop - is this code for current user or all users

I am trying to create a shortcut for all users using Wix 3.6. My InstallScope is perMachine and InstallPriviledges is elevated. I build this code ok. It runs ok. Does this produce a shortcut for all users or just the current user and what do I need to change to make a shortcut for all users?
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationDesktopShortcut" Guid="*">
<Shortcut Id="MyClient_DesktopShortcut" Name="My Client"
Description="My Client" Target="[INSTALLFOLDER]MyClient.exe"
WokingDirectory="INSTALLFOLDER" />
<RegistryValue Root="HKCU" Key="Software\MyServices\My Client\DesktopShortcut"
Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
Thanks
Jason

After install different versions of my application side-by-side, uninstall one version doesn't remove shortcut from program menu.

I created an installer using WIX. As part of the installation, two shortcuts (launch and uninstall) are added to "ProgramMenu->MyCompany->MyProductName".
After I install two versions of the same application side by side. I tried to use the uninstall shortcut to uninstall one version.
The uninstall removes all the files and folders for the version. But failed to remove the shortcuts. And when I click on uninstall again. The following error shows:
"This action is only valid for products that are currently installed"
Then I run the uninstall for the other version, this time both shortcuts for THAT version are removed successfully. But leave the shortcuts for the failed version stuck in "ProgramMenu->MyCompany->MyProductName" forever. I had to manually delete them.
Here is the code I use to create the shortcuts. Anything I did wrong?
<Directory Id="ProgramMenuFolder">
<Directory Id="MyCompanyShortcutDir" Name="MyCompany">
<Directory Id="MyProductShortcutDir" Name="MyProduct">
<Component Id="cmpMyProductShortcut" Guid="*">
<Shortcut Id="MyAppShortcut" Name="My App" Description="My Application" Target="[INSTALLFOLDER]MyApp.exe" />
<RemoveFolder Id="RemoveMyCompanyShortcutDir" On="uninstall" Directory="MyCompanyShortcutDir" />
<RegistryValue Root="HKCU" Key="Software\My Company\My Product\" Name="Installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Component Id="cmpUninstall" Guid="*">
<Shortcut Id="UninstallShortcut" Name="Uninstall" Description="Uninstall My App"
Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode] /Lv d:\uninstall.log " Directory="MyProductShortcutDir" />
<RegistryValue Root="HKCU" Key="[Software\My Company\My Product\" Name="Uninstall" Type="integer" Value="1" KeyPath="yes" />
<RemoveFolder Id="removeShortcut" On="uninstall"/>
</Component>
</Directory>
</Directory>
</Directory>
I solved this issue myself, basically two things needed:
Change the ProductCode to *, this allows side-by-side install of two versions.
Make sure the Component Guid for Shortcut to be * as well

Why Start menu shortcut is not removed after uninstallation?

When i installed .msi file, I am getting generated shortcuts on start menu and desktop, but when i am uninstalling the desktop shortcut getting removed but start menu. My code is bellow. Please help me to solve my problem. I have spent almost 1 day behind this.
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="Kiosk">
<Component Id="ApplicationShortcuts" Guid="12345678-1234-1234-1234-333333333333">
<Shortcut Id="ApplicationShortcut1" Name="Kiosk" Description="Solusoft Product" Target="[INSTALLDIR]AMP\1.0.0.0\mpkiosk.exe" WorkingDirectory="INSTALLDIR"/>
<RegistryValue Root="HKCU" Key="Software\Kiosk" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<RemoveFolder Id="ApplicationShortcut1" On="uninstall"/>
</Component>
</Directory>
</Directory>
In my case, on the component, I had GUID="*" and the shorcuts weren't removed.
I used a hardcoded GUID like: Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c" and the shortcuts were removed.
Regards.
You have a mistake in your code.
Instead of:
<RemoveFolder Id="ApplicationShortcut1" On="uninstall"/>
Use:
<RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/>
This should do it.
In my case, I was trying different options, and had a commented out section that had the same GUID. Changing it to a different GUID, even though the other was commented out, worked.
There is the code below that i'm using in my project. Hope, it will helps. I think you could use 'RemoveFile' instead 'RemoveFolder' and don't forget to put 'Name' attribute inside.
<RegistryKey Action="createAndRemoveOnUninstall" Root="HKCU"
Key="Software\$(var.ManufacturerEng)\$(var.ProductName)\$(var.ApplicationName)">
<RegistryValue Name="ShortcutService"
Type="integer" Value="1"
KeyPath="yes">
</RegistryValue>
</RegistryKey>
<Shortcut Advertise="no" Directory="ApplicationProgramsFolder"
Name="ServiceCC"
Target="[INSTALLLOCATION]Service.exe"
Id="SHORTCUT_serv"
WorkingDirectory="INSTALLLOCATION">
</Shortcut>
<RemoveFile Id="remove_serviceshort" Name="ServiceCC" On="uninstall"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
</Component>
In my case it was a copy paste error. I was using the same Guid for the component as another product I had created a shortcut in that folder for. Hence on uninstall the removal of the icon failed