3

I am trying to create a shortcut in the common startup folder so when any user logs on my application is run. I am using the nuget package WinSharp version 1.0.36.2 to create an MSI installer.

Below is my Main from the WinSharp project. The idea is to install the app to program files and create a shortcut in the startup folder (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp). The commented out line that creates a shortcut on the desktop works fine. Building the current version gives the error:

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

Is there a different directory Id like Desktop that will work for the startup folder?

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();

Other threads I have seen but are for XML not C#:

Wix create shortcut in user startup folder

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

4

4 回答 4

0

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

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

于 2017-09-12T10:29:32.113 回答
0

接受的答案对我不起作用,它导致了错误ICE38: Component installs to user profile

对我有用的是使用注册表:

 new RegValue(RegistryHive.LocalMachine,
     @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
     "MyApplication",
     @"[INSTALLDIR]MyFolder\MyApp.exe"),
于 2017-06-23T19:42:08.810 回答
0

您可以%ProgramMenu\Startup%用于启动文件夹位置

于 2016-08-06T08:47:01.920 回答
0
  //This will create three shortcuts         
  project.FindFile(f => f.Name.EndsWith("myapp.exe"))        
            .First()        
            .Shortcuts = new[]{         
                    new FileShortcut("myapp", "INSTALLDIR"),         
                    new FileShortcut("myapp","%Desktop%"),        
                     new FileShortcut("myapp","%Startup%")         
  };      
于 2016-09-06T04:45:45.317 回答