NSIS Installer in autostart and start on finished installation

57 Views Asked by At

I have a little program in python, which is in an index.exe file. it requires a folder of images, calles img.

I want to install this program with a NSIS installer. the general installation for me looks like that:

Outfile "NN-Quicksupport-Installer-Server.exe"
InstallDir $PROGRAMFILES\NN-Quicksupport

Page Components
Page Directory
Page InstFiles

Section "Installiere NN-Quicksupport" SecInstall
    SetOutPath $INSTDIR
    File "index.exe"
    
    SetOutPath $INSTDIR\img ; Ändere den Ordner-Namen hier
    File /r "img\*.*"

SectionEnd

But now I want to get this installation in the autostart for all users on the system, and start my application, once the installation is finished, but I don't know how to do that.

I'm not very experienced in dealing with NSIS, and thge things I found in the documentation didn't really work for me as I want it to.

I tried a few things from the documentation, regarding the autostart and startup after installation, but nothing really worked for me

1

There are 1 best solutions below

0
Anders On
RequestExecutionLevel Admin
Name "My Product"
Outfile "NN-Quicksupport-Installer-Server.exe"
InstallDir $PROGRAMFILES\NN-Quicksupport

Page Components
Page Directory
Page InstFiles

Section "Installiere NN-Quicksupport" SecInstall
    SetOutPath $INSTDIR
    File "index.exe"
    WriteUninstaller "$INSTDIR\Uninst.exe"
    
    SetOutPath $INSTDIR\img ; Ändere den Ordner-Namen hier
    File /r "img\*.*"
SectionEnd

Section "Run at startup"
SetShellVarContext All
CreateDirectory $SMSTARTUP
CreateShortcut "$SMSTARTUP\$(^Name).lnk" "$INSTDIR\index.exe"
SectionEnd

# A better option is to use the Modern UI interface and the finish page...
Section "Run the program"
Exec '"$INSTDIR\index.exe"'
SectionEnd

Section Uninstall
Delete "$INSTDIR\index.exe"
Delete "$INSTDIR\Uninst.exe"
RMDir /R "$INSTDIR\img"
RMDir $INSTDIR
SetShellVarContext All
Delete "$SMSTARTUP\$(^Name).lnk"
SectionEnd

Forcing your application to run at startup for all users is a bit rude, perhaps just limit it to the current user...