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

后端 未结 2 2022
無奈伤痛
無奈伤痛 2020-12-29 10:29

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

相关标签:
2条回答
  • 2020-12-29 11:06

    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.

    0 讨论(0)
  • 2020-12-29 11:19

    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.

    0 讨论(0)
提交回复
热议问题