[Setup] AppName=STT AppVersion={#AppVersion} AppPublisher=zitlem AppPublisherURL=https://github.com/ChurchPresenter/STT DefaultDirName={autopf}\STT DefaultGroupName=STT OutputDir=..\..\Output OutputBaseFilename=STT-windows Compression=lzma2/ultra64 SolidCompression=yes PrivilegesRequired=admin ArchitecturesInstallIn64BitMode=x64compatible SetupIconFile=..\..\icon.ico ; Code signing: CI passes /DSignBuild plus /Ssigntool="..." when the ; WINDOWS_CERTIFICATE_PFX secret is configured; local builds stay unsigned. #ifdef SignBuild SignTool=signtool SignedUninstaller=yes #endif [Files] Source: "..\..\dist\STT\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs [Icons] Name: "{group}\STT"; Filename: "{app}\STT.exe"; Parameters: "--gui" Name: "{group}\Uninstall STT"; Filename: "{uninstallexe}" Name: "{commondesktop}\STT"; Filename: "{app}\STT.exe"; Parameters: "--gui"; Tasks: desktopicon [Tasks] Name: "desktopicon"; Description: "Create a &desktop shortcut"; GroupDescription: "Additional icons:" Name: "autostart"; Description: "Start STT automatically at &login"; GroupDescription: "Auto-start:" [Run] ; /TR is one argument holding a whole command line, so the program path needs its ; own quotes inside it (\" to schtasks). Without them Task Scheduler split ; "C:\Program Files\STT\STT.exe" at the space and ran "C:\Program" (0x80070002). Filename: "schtasks.exe"; Parameters: "/Create /TN ""STT"" /TR ""\""{app}\STT.exe\"" --headless"" /SC ONLOGON /RL HIGHEST /F"; Flags: runhidden; Tasks: autostart ; After a silent auto-update, immediately start the new binary via the scheduled task Filename: "schtasks.exe"; Parameters: "/Run /TN ""STT"""; Flags: runhidden nowait; Tasks: autostart ; After an interactive install, offer to launch the GUI Filename: "{app}\STT.exe"; Parameters: "--gui"; Description: "Launch STT now"; Flags: nowait postinstall skipifsilent [UninstallRun] Filename: "schtasks.exe"; Parameters: "/Delete /TN ""STT"" /F"; Flags: runhidden; RunOnceId: "RemoveTask" [Code] procedure KillRunningInstance(); var ResultCode: Integer; begin Exec('taskkill.exe', '/F /IM STT.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssInstall then KillRunningInstance(); end;