Wix 在用户启动文件夹中创建快捷方式 [英] Wix create shortcut in user startup folder

查看:39
本文介绍了Wix 在用户启动文件夹中创建快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个安装程序,使当前用户的程序在启动时运行.我可以创建快捷方式,但似乎无法放入正确的文件夹中.

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 -->

我不明白为什么这不起作用.如果我将 SetDirectoryValue 更改为 "[%APPDATA]\\Microsoft\\Windows\\",则快捷方式在该 Windows 中文件夹如预期,但如果我将其更改为 "[%APPDATA]\\Microsoft\\Windows\\Start Menu\\",则快捷方式不在该开始菜单文件夹中.我不知道 Wix 是否试图对开始"菜单文件夹做一些特别的事情,或者文件夹名称中的空格是否存在问题,或者是否有其他问题.

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.

文档 提到了 Value 使用 Formatted 语法,但没有提及任何有关空格的问题.此外,大多数公认的环境变量似乎不能解决这个问题(至少我还没有弄清楚),但如果这些有效,我就不必对一半的路径进行硬编码.

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?

推荐答案

为什么不直接使用 StartupFolder-property?这样您就不必为手动创建路径而烦恼.

Why not using directly the StartupFolder-property? This way you won't have to fiddle with all the odds of creating paths manually.

关于您为什么这不起作用的问题:我没有具体的答案,但您可以检查:

Regarding your question of why this doesn't work: I don't have a concrete answer, but you could check:

  • 安装日志文件报告的内容
  • 如果在两种情况下都正确安装了组件.

这篇关于Wix 在用户启动文件夹中创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆