c# - Wix# 使用 C# 而不是 XML 在公共(public)启动文件夹中创建快捷方式

标签 c# installation wixsharp

我正在尝试在公共(public)启动文件夹中创建一个快捷方式,以便在任何用户登录我的应用程序时运行。我正在使用 nuget 包 WinSharp 版本 1.0.36.2 创建 MSI 安装程序。

下面是我的 WinSharp 项目的 Main。这个想法是将应用程序安装到程序文件并在启动文件夹(C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp)中创建一个快捷方式。在桌面上创建快捷方式的注释行工作正常。构建当前版本给出错误:

Error ICE38: Component StartupFolder.EmptyDirectory installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.

是否有像 Desktop 这样的不同目录 ID 可用于启动文件夹?

var project = new ManagedProject("Plate Synthesis Listener Setup",
new Dir(@"%ProgramFiles%\myCompany/myApp",
    new File(@"..\myApp\bin\Debug\myApp.exe")
    {
        //Shortcuts = new[] {new FileShortcut("myApp", "%Desktop%")}
        Shortcuts = new[] {new FileShortcut("myApp", "StartupFolder")}
    },
    new Files(@"..\myApp\bin\Debug\*.dll"),
    new File(@"..\myApp\bin\Debug\myApp.exe.config")
    {
        GUID = new Guid("My new GUID"),
        ManagedUI = ManagedUI.Empty,
        Version = new Version(1, 0, 1)
    };

    project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
           .Add(Dialogs.Progress)
           .Add(Dialogs.Exit);

    project.BuildMsi();

我见过的其他线程是针对 XML 而不是 C# 的:

Wix create shortcut in user startup folder

How to : Making a program start on Windows startup with wix toolset?

最佳答案

这些都不适合我,但这个确实:

        project.ResolveWildCards().FindFile(f => f.Name.EndsWith("My.exe")).First()
            .Shortcuts = new[]{
            new FileShortcut("Shortcut name", @"%AppData%\Microsoft\Windows\Start Menu\Programs")
        };

主要区别在于使用@"%AppData%\Microsoft\Windows\Start Menu\Programs"。

关于c# - Wix# 使用 C# 而不是 XML 在公共(public)启动文件夹中创建快捷方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37616983/

相关文章:

c# - Azure移动后端首次查询失败

c# - 重命名 WCF 服务时的问题

ubuntu - Lua、nmap、sqlite3 和 ubuntu - 找不到模块 'luasql.sqlite3'

windows - 如何从 WDK 8.1 Toaster Sample Driver 安装 KMDF Filter Driver?

c# - 在wixsharp中为项目指定自定义许可文件

c# - Entity Framework Core 中等效的 SQL RIGHT 函数

c# - 缺少 System.web.mvc

installation - 如何更改 Homebrew 程序: "config" scripts exist outside your system or Homebrew directories的路径

c# - 使用 Wix# 构建 MSI 的递归 DirFiles

wix - 为什么安装程序在单击快捷方式后运行?