4

Updated with Complete Wix Project as per craigster

<?xml version="1.0" encoding="UTF-8"?>
<?define SourceDir = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug" ?>
<?define icon = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug\1Password.ico" ?>
<?define DesktopFolder = "H:\Desktop" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">  
    <Product Id="*" Name="APS" Language="1033" Version="1.3.0.0" Manufacturer="SS" UpgradeCode="890c447c-5a09-4abb-9b01-fadf5e64aad5">
      <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
        Description="APS 1.2"
        Comments="APS will assist you with changing your password with a single click!"
        Manufacturer="SS"
        InstallPrivileges="elevated"
        Platform="x86" />

      <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
      <MediaTemplate EmbedCab="yes" />

      <Feature Id="ProductFeature" Title="AutomatedIDSystemInstaller" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
      </Feature>
    </Product>

    <Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="APS" />
        </Directory>
      </Directory>
    </Fragment>
    <Fragment>
      <DirectoryRef Id="TARGETDIR">
        <Directory Id="DesktopFolder" />
      </DirectoryRef>
      <Icon Id="Password.ico" SourceFile="$(var.SourceDir)\1Password.ico" />
      <Property Id="ARPPRODUCTICON" Value="Password.ico" />
    </Fragment>

  <!-- The casing of 'ANOTHERLOCATION' and 'WindowsVolume' is very important here.
     Replace 'MyNewDir' with the correct name of the folder you want on
     WindowsVolume.
-->
    <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />


    <!--<Fragment>
    <Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
      <RegistryValue Id="RegShortcutDesktop" Root="HKCU"
              Key="SOFTWARE\APS\settings" Name="DesktopSC" Value="1"
              Type="integer" KeyPath="yes" />
      <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]APS.exe"
              Directory="DesktopFolder" Name="APS"
              IconIndex="0"
              WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
    </Component>
  </Fragment>-->

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
        <!-- <Component Id="ProductComponent"> -->
        <!-- TODO: Insert files, registry keys, and other resources here. -->
        <!-- </Component> -->
        <!--<Component Id="ProductComponents">
        <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">
          <Shortcut Id="APSShortcut" 
                    Name="APS"
                    Advertise="yes" 
                    Description="1-Click to Change all your passwords!" 
                    WorkingDirectory="INSTALLFOLDER" 
                    ShortName="APS"                      
                    Directory="DesktopFolder"/>
        </File>
      </Component>-->


        <Component Guid="{27E3322C-C85D-4451-A06D-21B524878CA0}">

          <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">

            <Shortcut Id="APSShortcut"
                      Name="APS"
                      Advertise="yes"
                      Description="1-Click to Change all your passwords!"
                      WorkingDirectory="INSTALLFOLDER"
                      ShortName="APS"
                      Directory="DesktopFolder" Icon="Password.ico" IconIndex="0" />
          </File>
        </Component>
        <Component Id="HtmlAgilityPack.dll" Guid="{119C78DC-EFE5-4C84-9583-17F3DE341EFC}">
          <File Id="HtmlAgilityPack.dll" Source="$(var.SourceDir)\HtmlAgilityPack.dll" KeyPath="yes" />
        </Component>
        <Component Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Guid="{D6DBE101-004B-4383-A5F5-7BF16EB0C0FC}">
          <File Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Source="$(var.SourceDir)\Microsoft.VisualBasic.PowerPacks.Vs.dll" KeyPath="yes" />
        </Component>
        <Component Id="rtools_setup_x64.exe" Guid="{622D3FCF-E3A0-4A12-99B0-E9D7F879CB16}">
          <File Id="rtools_setup_x64.exe" Source="$(var.SourceDir)\rtools_setup_x64.exe" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.application" Guid="{DB61CF4D-E785-44FD-BB95-D19F7D1619FB}">
          <File Id="AutomatedIDSystem.application" Source="$(var.SourceDir)\APS.application" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.exe.config" Guid="{3E1CD5E7-1AF7-47AF-9FE3-30CEC56EF950}">
          <File Id="AutomatedIDSystem.exe.config" Source="$(var.SourceDir)\APS.exe.config" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.exe.manifest" Guid="{07689029-E9E0-47C0-87D7-5A94FC959EDF}">
          <File Id="AutomatedIDSystem.exe.manifest" Source="$(var.SourceDir)\APS.exe.manifest" KeyPath="yes" />
        </Component>
        <Component Id="AutomatedIDSystem.pdb" Guid="{4D3FBB60-6F55-439E-A88B-ADE7AF7A7459}">
          <File Id="AutomatedIDSystem.pdb" Source="$(var.SourceDir)\APS.pdb" KeyPath="yes" />
        </Component>
        <!--<Component Id="AutomatedIDSystem.vshost.application" Guid="{684D3AC6-FC03-4E87-944B-2D897169CDDE}">
        <File Id="AutomatedIDSystem.vshost.application" Source="$(var.SourceDir)\APS.vshost.application" KeyPath="yes" />
      </Component>-->
        <Component Id="AutomatedIDSystem.vshost.exe" Guid="{478284E1-999D-481D-91B4-4F8F15B998A6}">
          <File Id="AutomatedIDSystem.vshost.exe" Source="$(var.SourceDir)\APS.vshost.exe" KeyPath="yes" />
        </Component>
        <!--<Component Id="AutomatedIDSystem.vshost.exe.config" Guid="{099D79F8-370D-40FE-A6C2-0B76B6397FC7}">
        <File Id="AutomatedIDSystem.vshost.exe.config" Source="$(var.SourceDir)\APS.vshost.exe.config" KeyPath="yes" />
      </Component>-->
        <!--<Component Id="AutomatedIDSystem.vshost.exe.manifest" Guid="{48F07333-9C5B-4894-961D-531C26874531}">
        <File Id="AutomatedIDSystem.vshost.exe.manifest" Source="$(var.SourceDir)\APS.vshost.exe.manifest" KeyPath="yes" />
      </Component>-->
        <Component Id="Password.ico" Guid="{99391003-D8EE-4E6A-98E2-393F2ECE09D8}">
          <File Id="Password.ico" Source="$(var.SourceDir)\1Password.ico" KeyPath="yes" />
        </Component>
        <Component Id="setup.bat" Guid="{0460C522-A02B-4C8B-A0EE-34F1AFF677D1}">
          <File Id="setup.bat" Source="$(var.SourceDir)\setup.bat" KeyPath="yes" />
        </Component>

        <Component Id="netframework" Guid="{6BFA9239-38C7-4040-9487-6A5D20315CA7}">
          <File Id="netframework" Source="$(var.SourceDir)\dotnetfx452_full_x86_x64.exe" KeyPath="yes" />
        </Component>

        <!--    <Component Id="DesktopShortcut" Directory="DesktopFolder"> -->
        <Component Id="ApplicationShortcutDesktop" Guid="902B784B-B1F0-4629-AAC9-D46845734248">
          <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="APS" Target="[INSTALLFOLDER]APS.exe" WorkingDirectory="INSTALLFOLDER" />
          <RemoveFolder Id="DesktopFolder" On="uninstall" />
          <RegistryValue Root="HKCU" Key="Software\APS" Name="installed" Type="integer" Value="1" KeyPath="yes" />
        </Component>
        <!--</Component>-->

      </ComponentGroup>
    </Fragment>
  </Wix>

After following the direction that craigster and it's providing warnings for line 31

 <SetDirectpry Id="DesktopFolder" Value="H:\Desktop" />

the warning on line 41 says

Show Details    Severity    Code    Description Project File    Line
    Error       The Wix element contains an unexpected child element 'SetDirectory'.    Product.wxs 41
    Warning     The element 'Wix' in namespace 'http://schemas.microsoft.com/wix/2006/wi' has invalid child element 'SetDirectory' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. List of possible elements expected: 'Fragment' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. Product.wxs 41

Please tell me what I need to do to my WIX to have a shortcut created on H:\Desktop

Also what do I need to remove because it's unnecessary/redundant.

software is fun
  • 7,286
  • 18
  • 71
  • 129
  • 1
    The install scope is per machine so "user" means "all users." – Tom Blodget Mar 27 '15 at 11:05
  • Did you get this resolved? An alternative solution would be to use a set property custom action that gets the path to the user desktop and then you install a component with the shortcut there. This wouldn't clean out all potential per user shortcuts on uninstall though, and you would need to run active setup or self repair per user to add to all user profiles when new users log in. – Stein Åsmul Apr 10 '15 at 21:37

3 Answers3

3

This is kinda of like this question

Wix toolset: create directory in root disk (system disk or c:\) and copy files inside

Here my full wxs file

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="PosBeQBSyncSetup" Language="1033" Version="1.9.26"     Manufacturer="CompanyName" UpgradeCode="79d05903-6471-46e9-913c-    a7b080adc03f">
 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"     />

<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of MyApp is already installed." />
<Icon Id="icon.ico" SourceFile="..\MyApp\Resources\qbicon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Feature Id="ProductFeature" Title="MyApp" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
</Feature>
<Feature Id="DesktopShortCut" Title="MyApp" Level="1">
  <ComponentGroupRef Id="DesktopShortcut" />
</Feature>
<Feature Id="AppProgramsShortCut" Title="MyApp" Level="1">
  <ComponentGroupRef Id="ProgramsShortcut" />
</Feature>

<UI />
</Product>
<Fragment>

<SetDirectory Id="DesktopFolder" Value="F:\Desktop" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="MyApp" />
  </Directory>
  <Directory Id="CommonAppDataFolder">
    <Directory Id="DataFolder" Name="MyApp" />
  </Directory>
  <Directory Id="DesktopFolder" Name="Desktop" />
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="MyApp" />
  </Directory>
</Directory>

</Fragment>
<Fragment>
<ComponentGroup Id="DesktopShortcut" Directory="DesktopFolder">
  <Component Id="ApplicationShortcutDesktop" Guid="FF285292-BB8A-4012-96E4-70C126B2F030">
    <Shortcut Id="ApplicationDesktopShortcut" Name="MyApp" Description="MyApp" Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER"  />
    <RemoveFolder Id="DesktopFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software\MyApp" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>
<ComponentGroup Id="ProgramsShortcut" Directory="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcut" Guid="664186E9-BD9D-4555-A1AA-571BA31AD990">
    <Shortcut Id="ApplicationStartMenuShortcut" Name="MyApp" Description="MyApp" Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER" />
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software/MyApp" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
  <Component Id="MyApp.exe">
    <!-- TODO: Insert files, registry keys, and other resources here. -->
    <File Source="..\MyApp\bin\Release\MyApp.exe" />
  </Component>
  </ComponentGroup>
  </Fragment>
  </Wix>

Also here what you need to add these three section to your wxs file. Don't forget the feature section

Add this to the feature section

<Feature Id="DesktopShortCut" Title="AppName" Level="1">
  <ComponentGroupRef Id="DesktopShortcut" />
</Feature>

Add this to your directories section

  <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />
  <Directory Id="DesktopFolder" Name="Desktop" />

Also add this CompenentGroup

  <ComponentGroup Id="DesktopShortcut" Directory="DesktopFolder">
  <Component Id="ApplicationShortcutDesktop" Guid="FF285292-BB8A-4012-96E4-70C126B2F030">
    <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="AppName" Target="[INSTALLFOLDER]AppName.exe" WorkingDirectory="INSTALLFOLDER" />
    <RemoveFolder Id="DesktopFolder" On="uninstall" />
    <RegistryValue Root="HKCU" Key="Software\AppName" Name="installed" Type="integer" Value="1" KeyPath="yes" />
  </Component>
</ComponentGroup>

Your file should look like this

<?xml version="1.0" encoding="UTF-8"?>
<?define SourceDir = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug" ?>
<?define icon = "C:\Users\BillSmith\Documents\Visual Studio 2015\Projects\AIS\AIS\bin\Debug\1Password.ico" ?>
<?define DesktopFolder = "H:\Desktop" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">  
<Product Id="*" Name="APS" Language="1033" Version="1.3.0.0" Manufacturer="SS" UpgradeCode="890c447c-5a09-4abb-9b01-fadf5e64aad5">
  <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
    Description="APS 1.2"
    Comments="APS will assist you with changing your password with a single click!"
    Manufacturer="SS"
    InstallPrivileges="elevated"
    Platform="x86" />

  <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
  <MediaTemplate EmbedCab="yes" />

  <Feature Id="ProductFeature" Title="AutomatedIDSystemInstaller" Level="1">
    <ComponentGroupRef Id="ProductComponents" />
  </Feature>
</Product>

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="APS" />
    </Directory>
  </Directory>
</Fragment>
<Fragment>
  <DirectoryRef Id="TARGETDIR">
    <Directory Id="DesktopFolder" />
  </DirectoryRef>
  <Icon Id="Password.ico" SourceFile="$(var.SourceDir)\1Password.ico" />
  <Property Id="ARPPRODUCTICON" Value="Password.ico" />
</Fragment>

<!--<Fragment>
<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
  <RegistryValue Id="RegShortcutDesktop" Root="HKCU"
          Key="SOFTWARE\APS\settings" Name="DesktopSC" Value="1"
          Type="integer" KeyPath="yes" />
  <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]APS.exe"
          Directory="DesktopFolder" Name="APS"
          IconIndex="0"
          WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
</Component>
</Fragment>-->

<Fragment>
  <SetDirectory Id="DesktopFolder" Value="H:\Desktop" />
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
    <!-- <Component Id="ProductComponent"> -->
    <!-- TODO: Insert files, registry keys, and other resources here. -->
    <!-- </Component> -->
    <!--<Component Id="ProductComponents">
    <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">
      <Shortcut Id="APSShortcut" 
                Name="APS"
                Advertise="yes" 
                Description="1-Click to Change all your passwords!" 
                WorkingDirectory="INSTALLFOLDER" 
                ShortName="APS"                      
                Directory="DesktopFolder"/>
    </File>
  </Component>-->


    <Component Guid="{27E3322C-C85D-4451-A06D-21B524878CA0}">

      <File Source="$(var.AutomatedIDSystem.TargetPath)" KeyPath="yes">

        <Shortcut Id="APSShortcut"
                  Name="APS"
                  Advertise="yes"
                  Description="1-Click to Change all your passwords!"
                  WorkingDirectory="INSTALLFOLDER"
                  ShortName="APS"
                  Directory="DesktopFolder" Icon="Password.ico" IconIndex="0" />
      </File>
    </Component>
    <Component Id="HtmlAgilityPack.dll" Guid="{119C78DC-EFE5-4C84-9583-17F3DE341EFC}">
      <File Id="HtmlAgilityPack.dll" Source="$(var.SourceDir)\HtmlAgilityPack.dll" KeyPath="yes" />
    </Component>
    <Component Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Guid="{D6DBE101-004B-4383-A5F5-7BF16EB0C0FC}">
      <File Id="Microsoft.VisualBasic.PowerPacks.Vs.dll" Source="$(var.SourceDir)\Microsoft.VisualBasic.PowerPacks.Vs.dll" KeyPath="yes" />
    </Component>
    <Component Id="rtools_setup_x64.exe" Guid="{622D3FCF-E3A0-4A12-99B0-E9D7F879CB16}">
      <File Id="rtools_setup_x64.exe" Source="$(var.SourceDir)\rtools_setup_x64.exe" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.application" Guid="{DB61CF4D-E785-44FD-BB95-D19F7D1619FB}">
      <File Id="AutomatedIDSystem.application" Source="$(var.SourceDir)\APS.application" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.exe.config" Guid="{3E1CD5E7-1AF7-47AF-9FE3-30CEC56EF950}">
      <File Id="AutomatedIDSystem.exe.config" Source="$(var.SourceDir)\APS.exe.config" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.exe.manifest" Guid="{07689029-E9E0-47C0-87D7-5A94FC959EDF}">
      <File Id="AutomatedIDSystem.exe.manifest" Source="$(var.SourceDir)\APS.exe.manifest" KeyPath="yes" />
    </Component>
    <Component Id="AutomatedIDSystem.pdb" Guid="{4D3FBB60-6F55-439E-A88B-ADE7AF7A7459}">
      <File Id="AutomatedIDSystem.pdb" Source="$(var.SourceDir)\APS.pdb" KeyPath="yes" />
    </Component>
    <!--<Component Id="AutomatedIDSystem.vshost.application" Guid="{684D3AC6-FC03-4E87-944B-2D897169CDDE}">
    <File Id="AutomatedIDSystem.vshost.application" Source="$(var.SourceDir)\APS.vshost.application" KeyPath="yes" />
  </Component>-->
    <Component Id="AutomatedIDSystem.vshost.exe" Guid="{478284E1-999D-481D-91B4-4F8F15B998A6}">
      <File Id="AutomatedIDSystem.vshost.exe" Source="$(var.SourceDir)\APS.vshost.exe" KeyPath="yes" />
    </Component>
    <!--<Component Id="AutomatedIDSystem.vshost.exe.config" Guid="{099D79F8-370D-40FE-A6C2-0B76B6397FC7}">
    <File Id="AutomatedIDSystem.vshost.exe.config" Source="$(var.SourceDir)\APS.vshost.exe.config" KeyPath="yes" />
  </Component>-->
    <!--<Component Id="AutomatedIDSystem.vshost.exe.manifest" Guid="{48F07333-9C5B-4894-961D-531C26874531}">
    <File Id="AutomatedIDSystem.vshost.exe.manifest" Source="$(var.SourceDir)\APS.vshost.exe.manifest" KeyPath="yes" />
  </Component>-->
    <Component Id="Password.ico" Guid="{99391003-D8EE-4E6A-98E2-393F2ECE09D8}">
      <File Id="Password.ico" Source="$(var.SourceDir)\1Password.ico" KeyPath="yes" />
    </Component>
    <Component Id="setup.bat" Guid="{0460C522-A02B-4C8B-A0EE-34F1AFF677D1}">
      <File Id="setup.bat" Source="$(var.SourceDir)\setup.bat" KeyPath="yes" />
    </Component>

    <Component Id="netframework" Guid="{6BFA9239-38C7-4040-9487-6A5D20315CA7}">
      <File Id="netframework" Source="$(var.SourceDir)\dotnetfx452_full_x86_x64.exe" KeyPath="yes" />
    </Component>

    <!--    <Component Id="DesktopShortcut" Directory="DesktopFolder"> -->
    <Component Id="ApplicationShortcutDesktop" Guid="902B784B-B1F0-4629-AAC9-D46845734248">
      <Shortcut Id="ApplicationDesktopShortcut" Name="AppName" Description="APS" Target="[INSTALLFOLDER]APS.exe" WorkingDirectory="INSTALLFOLDER" />
      <RemoveFolder Id="DesktopFolder" On="uninstall" />
      <RegistryValue Root="HKCU" Key="Software\APS" Name="installed" Type="integer" Value="1" KeyPath="yes" />
    </Component>
    <!--</Component>-->

  </ComponentGroup>
</Fragment>

Community
  • 1
  • 1
craigster
  • 124
  • 1
  • 6
  • Thanks. I am new to WiX. What is a feature section? – software is fun Mar 25 '15 at 13:39
  • I missed a line here is the important line – craigster Mar 25 '15 at 14:32
  • I just added more examples – craigster Mar 25 '15 at 14:38
  • I must be doing something wrong. I am getting warnings Show Details Severity Code Description Project File Line Warning The element 'DirectoryRef' in namespace 'http://schemas.microsoft.com/wix/2006/wi' has invalid child element 'SetDirectpry' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. List of possible elements expected: 'Component, Directory, Merge' in namespace 'http://schemas.microsoft.com/wix/2006/wi' as well as any element in namespace '##other'. – software is fun Mar 26 '15 at 12:09
  • This appears to be creating the icon on the Public Desktop – software is fun Mar 26 '15 at 13:48
  • Looks like SetDirectory is spelled wrong all you should have add yet is – craigster Mar 27 '15 at 16:34
  • Also make sure SetDirectory isn't in the Directory Tag it should only be under the product tag and the wix tag – craigster Mar 27 '15 at 16:37
  • I added SetDirectory above – software is fun Mar 30 '15 at 16:35
  • You want inside the Wix tag and inside the Product tag but not inside any other tags and after your directory tags – craigster Mar 30 '15 at 17:48
  • The first example in my answer show where the SetDirectory tag should be. – craigster Mar 30 '15 at 17:50
  • In your first example,I get this error. Show Details Severity Code Description Project File Line Error The Wix element contains an unexpected child element 'SetDirectory'. Product.wxs 41 Warning The element 'Wix' in namespace 'http://schemas.microsoft.com/wix/2006/wi' has invalid child element 'SetDirectory' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. List of possible elements expected: 'Fragment' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. Product.wxs 41 – software is fun Mar 31 '15 at 14:08
  • I updated my question with your suggestion. Please take a look at the WiX. @craigster – software is fun Mar 31 '15 at 14:14
  • I updated the Full example to my Product.wxs file I just tried this file again and it worked just change F:\Desktop your path. That error you are getting is xml formating related – craigster Apr 02 '15 at 14:34
  • I just added what your file should look like on the bottom of my answer. Hope it works – craigster Apr 02 '15 at 14:42
2

You should not assign a value to DesktopFolder yourself. In fact I am surprised you are even able to. The DesktopFolder Property is set by Windows installer itself during FileCosting (standard operation during installation).

Due to the special concept of a per-user and per-machine installation (installation context) being controlled by the value of the ALLUSERS property, the path of this property can point to either the user's desktop folder, or that of the all user's desktop folder:

  • C:\Users\UserName\Desktop
  • C:\Users\Public\Desktop

This rather usless concept (installation context) causes a lot of confusion. The consensus seems to be that it is best to set ALLUSERS=1 for a per-machine installation. They are easier to manage. Per user installation allows for the incredible concept that the same setup is installed repeatedly for different users, making upgrades, cleanup, uninstall and patching hard. There are many other issues too, here is an article on the subject (this is a good read): http://www.indigorose.com/webhelp/sufwi/Concepts/Per-Machine_vs._Per-User_Installations.htm


I would provide you with a real sample if I had access to my script repository, but I don't at the moment. Instead, please try this well known Wix tutorial (towards the bottom): http://wix.tramontana.co.hu/tutorial/net-and-net/launch-the-internet

Here is just the code from the tutorial inline:

<Property Id="URL" Value="http://www.something.com" />
<Shortcut Id="WebShortcut" Name="Web URL" Description="Jump to our website" Target="[URL]" />

Here are two other samples:


If you want to create the folder via VBScript here is a quick example:

' Add a shortcut on the users desktop

Const DESKTOPFOLDER= 16

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESKTOPFOLDER) 
Set objFolderItem = objFolder.Self     

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objFolderItem.Path
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\MSDN.url")
objURLShortcut.TargetPath = "http://msdn.microsoft.com"
objURLShortcut.Save

Note that you will need to add a script to delete such a shortcut on uninstall. To clean up for all users on the desktop you would need to use ActiveSetup (maybe read this post too on ActiveSetup) and register a cleanup job since the cleanup would happen on their next logon. This can be a huge headache since the setup could be reinstalled by them (same or new version), and then you need to cancel any pending per user cleanup operations.


For the record, and this is a time saver, you can also greatly simplify your Wix XML by relying on default attribute values for many items. See more details in this post: Syntax for guids in WIX?

Quick sample. This is sufficient:

<Component>
  <File Source="..\File.dll" />
</Component>

as opposed to

<!-- Sample guid below, do not copy paste -->
<Component Id="File.dll" Guid="{12345678-1234-1234-1234-123456789ABC}">
  <File Id="File.dll" Name="File.dll" KeyPath="yes" Source="..\File.dll" />
</Component>
Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Stein - thank you. I would love to keep in touch with you via email or something. WiX is one confusing monster – software is fun Apr 07 '15 at 18:20
  • Is there a critical need to add the shortcut per user? I generally do such things with a custom action and VBScripting if really needed. Otherwise I let the installation go down per-machine and let the application itself deal with all data written to HKCU. – Stein Åsmul Apr 07 '15 at 18:23
  • Yea we are using SCCM to install the software on users computers. However we need the shortcut on their Desktop and not Public (since you need Admin access to delete it) – software is fun Apr 07 '15 at 18:25
  • Is it an option to put the shortcut in a common start menu location? Where it doesn't clutter the user's desktop? Programs => Shared Business Applications or similar? – Stein Åsmul Apr 07 '15 at 18:31
  • I have updated the answer with some more details. Reads a bit confusing I think, please follow the links on ActiveSetup for a better explanation. – Stein Åsmul Apr 07 '15 at 18:54
  • My recommendation would be a **per-machine install** with a shortcut put in a shared location that doesn't clutter the desktop. Avoid writing any per user data with your setup if you can (HKCU, userprofile) - this simplifies upgrades and deployment in general. Make your application capable of populating the per user sections with default values upon first launch so nothing per-user needs to be written by your setup. I have written about **deployment of user data** here: http://forum.installsite.net/index.php?showtopic=21552 – Stein Åsmul Apr 07 '15 at 19:03
1

I had trouble with this myself. Here is a project template that works:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="243604BF-62BC-4B9B-BFA7-8BD43DE096B9" Name="JTsApp" Language="1033" Version="1.4.0.0" Manufacturer="JT Pty Ltd" UpgradeCode="CEFF1611-50E1-4DC9-BC60-548A76312AA5">
    <Package Description="JTsApp Installer" Comments="JTsApp" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Upgrade Id="{CEFF1611-50E1-4DC9-BC60-548A76312AA5}">
      <UpgradeVersion Minimum="1.0.4" IncludeMinimum="yes" Maximum="1.4.0" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
    </Upgrade>

    <Icon Id="favicon.ico" SourceFile="JTsApp.ico"/>
    <Property Id="ARPPRODUCTICON" Value="favicon.ico" />

    <!--Ref: http://stackoverflow.com/questions/2058230/wix-create-non-advertised-shortcut-for-all-users-per-machine
    <Property Id="DISABLEADVTSHORTCUTS" Value="1" />-->

    <Feature Id="ProductFeature" Title="JTsApp" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ProgramMenuDir"/>
    </Feature>

    <Media Id="1" Cabinet="JTsApp.cab" EmbedCab="yes" />

    <!--<PropertyRef Id="NETFRAMEWORK40FULL" />
    <Condition Message="This application requires .NET Framework 4.0.">
      <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
    </Condition>-->

    <UIRef Id="MyWixUI_Minimal" />

    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallInitialize"/>
    </InstallExecuteSequence>

</Product>

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="DesktopFolder" SourceName="Desktop" />

    <Directory Id="ProgramMenuFolder" Name="Programs">
      <Directory Id="ApplicationProgramsFolder" Name="JTsApp">
        <Component Id="ProgramMenuDir" Guid="F8F34900-78DC-43FD-8C24-FC8A2401981D">
          <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
          <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\JTsApp" Type="integer" Value="1" Name="installed" KeyPath="yes" />
        </Component>
      </Directory>
    </Directory>

    <Directory Id="ProgramFilesFolder">
      <Directory Id="ManufacturerFolder" Name="JTs Pty Ltd">
        <Directory Id="INSTALLFOLDER" Name="JTsApp">
        </Directory>
      </Directory>
    </Directory>

  </Directory>

</Fragment>

<Fragment>
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <!--Core Application-->
    <Component Id="TouchTypingWizard_Component">
    <File Id="TouchTypingWizard.exe" KeyPath="yes" Name="TouchTypingWizard.exe" Source="C:\1A\WiXsInstallerTemplate\SetupProject1\TouchTypingWizard\bin\Debug\TouchTypingWizard.exe" />

      <Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR" Advertise="yes" Icon="favicon.ico" IconIndex="0" />
      <Shortcut Id="ExeShortcut" Directory="ApplicationProgramsFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR"  Advertise="yes" Icon="favicon.ico" IconIndex="0" />

    </Component>

    <Component Id="JTsApp_DefaultIcon_RegKey">
      <RegistryValue Id="JTsApp_DefaultIcon_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Value="" Type="string" KeyPath="yes" />
    </Component>

    <Component Id="JTsApp_DefaultIcon_exe_RegKey_Component">
      <RegistryValue Id="JTsApp_DefaultIcon_exe_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Name="Default" Value="TouchTypingWizard.exe,1" Type="string" KeyPath="yes" />
    </Component>

  </ComponentGroup>
</Fragment>

</Wix>

You can see I tried a lot of things and I haven't taken the time to narrow it down. I believe these lines are the key:

   <Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
 Name="JTsApp" WorkingDirectory="INSTALLDIR" Advertise="yes"
 Icon="favicon.ico" IconIndex="0" />
       <Shortcut Id="ExeShortcut" Directory="ApplicationProgramsFolder" Name="JTsApp" WorkingDirectory="INSTALLDIR"  Advertise="yes"
 Icon="favicon.ico" IconIndex="0" />

Although, I haven't ruled out these lines:

 <Component Id="JTsApp_DefaultIcon_exe_RegKey_Component">
           <RegistryValue Id="JTsApp_DefaultIcon_exe_RegKey" Root="HKCR" Key="JTsApp\DefaultIcon" Name="Default"
 Value="TouchTypingWizard.exe,1" Type="string" KeyPath="yes" />
         </Component>

Anyway, here is proof it works:

enter image description here

Here are the files in the setup project directory:

enter image description here

Here is what the solution looks like:

enter image description here

^^ Note: I reference the C:\Program Files\WiX Toolset v3.8\bin\WixUIExtension.dll and I include the MyWixUI_Minimal.wxs file.

Here is the Setup Project for you to download and confirm it works:

http://tempsend.com/09604C06D6

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • I have that as well in the Fragment section. Does it need to be nested within ? What lines actually create the Icon? I need it on the H:\Desktop and if the H:\Desktop is not accessible or available then keep going – software is fun Apr 06 '15 at 15:24
  • Severity Code Description Project File Line Error Found orphaned Component 'ProgramMenuDir'. If this is a Product, every Component must have at least one parent Feature. To include a Component in a Module, you must include it directly as a Component element of the Module element or indirectly via ComponentRef, ComponentGroup, or ComponentGroupRef elements. APS D:\Projects\VSStudio\APSInstaller\Product.wxs 46 – software is fun Apr 06 '15 at 15:29
  • Put the icon in the same directory as the wxs file, I don't think *SourceFile="$(var.SourceDir)\1Password.ico"* is correct. If that doesn't work I'll zip up a working WIX project and upload it to a temp share for you this arvo. – Jeremy Thompson Apr 06 '15 at 22:48
  • I am getting the icon on the Desktop but it's the C:\Users\Public\Desktop – software is fun Apr 07 '15 at 12:20
  • Yes, my script is HKMU - for all users. If you want 'per user' not machine wide you'll need to change the **InstallScope="perMachine"** – Jeremy Thompson Apr 07 '15 at 12:24