27

I'm exploring distribution of .NET desktop applications with MSI generated by WiX.

So far it works great. But I've got a few questions, googling can't help out with.

What's the advised way of registering application to start when windows launches (in WiX)?

What WixUI could I use and how?

Notes:

  • The application is not a Windows Service and should not be registered as such.
  • It would be nice to let user to disable that option in the setup process.

Thanks in advance!

Rinat Abdullin
  • 23,036
  • 8
  • 57
  • 80

3 Answers3

47

I found this using Google (Providing automatic program start via the Registry); it also includes adding UI. Don't forget you should also provide an option outside the setup to enable/disable autostart.

The basic Wix for it is:

  <Property Id="ASSISTANCE_START_VIA_REGISTRY">1</Property>

  <!-- Auto-start via Registry -->
  <Component Id="MerliniAssistanceAutostart" Guid="Place-your-own-GUID-here">
    <RegistryValue Id="MerAs.rst" Root="HKMU" Action="write"
                   Key="Software\Microsoft\Windows\CurrentVersion\Run"
                   Name="Merlinia Assistance Client"
                   Value="[INSTALLDIR]Assistance.exe"
                   Type="string" />
    <Condition>ASSISTANCE_START_VIA_REGISTRY</Condition>
  </Component>

  <ComponentRef Id="MerliniaAssistanceAutostart" />
llaforest
  • 5
  • 4
Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87
  • Apparently there are some benefits to starting off a shortcut instead of directly off the .exe. – tofutim Apr 24 '12 at 16:35
  • @tofutim Care to elaborate more? – Shay Erlichmen Apr 24 '12 at 16:39
  • If AutoStart points to the lnk in the StartMenu, you could modify the Start Menu shortcut parameters and have AutoStart start that version. – tofutim Apr 25 '12 at 00:39
  • 19
    If you give your `` an Id, you can put `[#FileId]` as the `Value` instead of `[INSTALLDIR]Assistance.exe`. That way, if you change the name of the exe file, or its location or whatever, that field will be automatically updated and kept in sync. – Alex Jun 21 '12 at 12:10
  • I tried this, but the Application did not start on startup by this. Is there a known issue ? – Naveed Butt Jun 02 '16 at 07:06
  • 2
    I suppose Root="HKMU" should be Root="HKCU"… – mat007 Aug 17 '18 at 09:28
13

Take a look in the registry at HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. If you want it to start per-user then look in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. If you want it to start when Windows starts, without requiring a user to log on, that's a Service.

Dave Markle
  • 95,573
  • 20
  • 147
  • 170
0

I would suggest you ask the user with a custom form if the application should startup automatically and then create a link in the users startup folder.

Oliver Friedrich
  • 9,018
  • 9
  • 42
  • 48