Inno Setup - how can I make my program run when a user logs in to Windows?

Keith Palmer Jr. picture Keith Palmer Jr. · Sep 20, 2011 · Viewed 13.2k times · Source

I want to use Inno Setup (http://www.jrsoftware.org/isfaq.php) to build an installer for an application.

I want this application to start whenever a user logs in to their account on the Windows machine.

How can I tell Inno Setup to make the program start when a user logs in?

Answer

Sertac Akyuz picture Sertac Akyuz · Sep 20, 2011

Put a shortcut in the startup folder of All Users profile. See the knowledge base article 'Create shortcuts in the Startup (or Autostart) group' which includes the below example:

[Setup]
PrivilegesRequired=admin

[Icons] 
Name: "{commonstartup}\My Program"; Filename: "{app}\MyProg.exe"

If you want the program to run only when the user that installed the program logs in, then use {userstartup} instead of {commonstartup}. In that case admin privileges is not required.


Or if you decide to write to 'Run' key of registry (kb article):

[Registry]
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyProg"; ValueData: """{app}\MyProg.exe"""; Flags: uninsdeletevalue

If you use 'HKLM', again admin privileges is required.