Inno Setup - how can I make my program run when a

2019-02-03 17:09发布

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?

标签: inno-setup
2条回答
Anthone
2楼-- · 2019-02-03 17:39

Maybe it would be helpful for someone...

I encountered some problems under windows 8 when trying to build setup that would automatically put autorun registry key such as:

Root: "HKCU"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "NHMMNAS"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletevalue

for running my 32-bit .NET application on every Windows startup. It occured that for 32-bit application a little modification was needed which was replacing Root: "HKCU" with Root: "HKCU32" so the entry in setup script was:

Root: "HKCU32"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "NHMMNAS"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletevalue

After adding the line and reinstalling, my application started on system startup with no problems.

查看更多
Melony?
3楼-- · 2019-02-03 17:42

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.

查看更多
登录 后发表回答