WiX: How to register application to start when Windows launches?

假装没事ソ 提交于 2020-01-09 16:50:08

问题


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!


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/1052698/wix-how-to-register-application-to-start-when-windows-launches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!