1

How do I make my executable file start with Windows in Visual Studio's Windows Installation project (MSI setup creator)?

Tried to add registry keys, look into 'Assembly' properties. I have the MSI project compile and it installs fine to the folder but I need it to run

a) After installation is complete b) Every time Windows starts.

Thank you

Yura
  • 65
  • 1
  • 10
  • 1
    It might be worth looking here for launching the EXE after install: https://stackoverflow.com/a/3169040/4181058 and also here to launch the exe after each login: https://learn.microsoft.com/en-us/windows/desktop/setupapi/run-and-runonce-registry-keys – Captain_Planet Jun 18 '19 at 06:50

1 Answers1

0

On Scheduled Tasks versus Windows Services. See this previous answer for longer descriptions of the below summary items. I don't use this installer tools, so detailed steps I can't do right now.

When should I use a scheduled task instead of a Windows Service?

Startup Folder: You can use the Windows startup folder as suggested here - allusers:

  • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
  • C:\Users\<user-name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Quick access: Windows logo key + R => shell:startup.

Windows Service: Windows services are usually set to run on boot / system startup. They can also start on demand or be disabled. There used to be a tool called Microsoft SRVANY allowing applications to run as services (how-to), but I am not sure how well it works anymore.

Scheduled Task: It is possible to launch tasks on every boot using the task scheduler. These can run as a specific user.

AutoRun Registry: You can register something to run on login in the registry - Run and RunOnce Registry Keys:

  • HKCU\Software\Microsoft\Windows\CurrentVersion\Run
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  • HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Drivers: I suppose one can mention drivers as well. They load on startup. They need signing and the complexity is high. Nobody should use this for anything casual - to state the obvious.

Group Policy: Group policy can run specific programs on logon - either for a specific user or for all users. How to Run Programs Automatically When a User Logs On (Winkey + R => gpedit.msc):

All computer users:

Computer Configuration\Administrative Templates\System\Run These Programs at User Logon

Specific user:

User Configuration\Administrative Templates\System\Run These Programs at User Logon

Autoruns.exe: Sysinternals has the tool autoruns.exe which will show you just how many ways there are to start something on system startup:

autoruns.exe


Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164