I'm trying to create an installer that makes the program run on startup for the current user. I can create a shortcut, but I can't seem to put in the right folder.
<!-- some wix stuff -->
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<!-- more wix stuff -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- more directory stuff -->
<Directory Id="UserStartupFolder"/>
</Directory>
<SetDirectory Id="UserStartupFolder" Value="[%APPDATA]\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\"/>
<!-- more wix stuff -->
<DirectoryRef Id="UserStartupFolder">
<Component Id="StartupFolderShortcut" Guid="MyGUID">
<Shortcut Id="StartupFolderShortcut" Name="MyShortcut" Description="$(var.description)" Target="[#MainExecutable]" WorkingDirectory="INSTALLFOLDER"/>
<RegistryValue Root="HKCU" Key="Software\$(var.companyDisplayName)\$(var.projectDisplayName)\UserStartupItem" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<!-- more wix stuff -->
I don't understand why this doesn't work. If I change the Value
of SetDirectory
to "[%APPDATA]\\Microsoft\\Windows\\"
, the shortcut is in that Windows folder as expected, but if I change it to "[%APPDATA]\\Microsoft\\Windows\\Start Menu\\"
, the shortcut isn't in that Start Menu folder. I don't know if Wix tries to do something special with the Start Menu folder or if there is an issue with the space in the folder name or if it's something else.
The documentation mentions that Value
uses the Formatted syntax, but it doesn't mention anything about spaces being an issue. Also, most of the recognized environment variables don't seem to work with this (at least I haven't figured it out), but if those worked, I wouldn't have to hard-code half the path.
How do I create the shortcut in the user's startup folder?