.NET: How to add launch on startup option to ClickOnce installer

72 Views Asked by At

following the guide Deploy a .NET Windows Desktop app with ClickOnce for Visual Studio, I have created a ClickOnce installer named setup.exe. Is it possible to add an extra step to the installer where the user, via checkbox or other means, would be asked to check or uncheck the option to allow the installed application automatic launch on Windows startup?

If it is not possible to ask it in the ClickOnce installer, is there another easy way of creating an installer with this option? Or is the only way to ask for launch on startup doing it manually in the application code as, for example, the answers in the following question suggest?

I am developing a WPF desktop application in C# targetting .NET 8.0.

1

There are 1 best solutions below

0
J.Memisevic On

Not sure if this is option using a ClickOnce installer, but I know that you can achieve this with NSIS (Nullsoft Scriptable Install System). Where startup of application can be set on User or System scope - meaning application will be started when user logs in or it will be started when System is started.

Something like this :

Section "MainSection" SEC01
    SetOutPath "$INSTDIR"
    File "MyApplication.exe"
    
    ; Add application to startup for current user
    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "MyApplication" "$INSTDIR\MyApplication.exe"
SectionEnd

NSIS can a bit of learning curve since it is script-based and allows for creating installers that can manage complex installation tasks.

If you find some other installers that are simpler for your application to be started at startup is in to place them in Hive Key windows registry. See