22; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33; Non-commercial use only
44#define MyAppName " Wormhole"
5- #define MyAppVersion " 1.2.0 "
5+ #define MyAppVersion " 1.2.1 "
66#define MyAppPublisher " Nova Foundry"
77#define MyAppURL " novafoundry.ca/wormhole"
88#define MyAppExeName " wormhole.exe"
@@ -30,9 +30,11 @@ ArchitecturesAllowed=x64compatible
3030ArchitecturesInstallIn64BitMode = x64compatible
3131DisableProgramGroupPage = yes
3232LicenseFile = C:\Users\jackp\Downloads\Wormhole\LICENSE.txt
33- ; Uncomment the following line to run in non administrative install mode (install for current user only).
34- ;PrivilegesRequired=lowest
33+
34+ ; *** MODIFICATION: Chocolatey requires Admin rights ***
35+ PrivilegesRequired = admin
3536PrivilegesRequiredOverridesAllowed= dialog
37+
3638OutputDir = C:\Users\jackp\Downloads
3739OutputBaseFilename = Wormhole_setup
3840SetupIconFile = C:\Users\jackp\Downloads\Installer Icon template.ico
@@ -140,15 +142,12 @@ begin
140142 end ;
141143
142144 // 4. Verify installation using full path (since PATH may not update yet)
143- // Primary path for 64-bit all-users install
144145 PandocExePath := ExpandConstant(' {commonpf}\Pandoc\pandoc.exe' );
145146 if not FileExists(PandocExePath) then
146147 begin
147- // Fallback: Check x86 Program Files (older or misconfigured installs)
148148 PandocExePath := ExpandConstant(' {pf}\Pandoc\pandoc.exe' );
149149 if not FileExists(PandocExePath) then
150150 begin
151- // Fallback: Per-user install (if ALLUSERS failed)
152151 PandocExePath := ExpandConstant(' {localappdata}\Programs\Pandoc\pandoc.exe' );
153152 if not FileExists(PandocExePath) then
154153 begin
@@ -158,7 +157,6 @@ begin
158157 end ;
159158 end ;
160159
161- // Run --version with full path
162160 if not Exec(PandocExePath, ' --version' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode) or (ResultCode <> 0 ) then
163161 begin
164162 Result := ' Pandoc installed but --version failed even with full path. Code: ' + IntToStr(ResultCode);
@@ -169,61 +167,112 @@ begin
169167 Result := ' ' ; // Success
170168end ;
171169
170+ // *** NEW FUNCTION: Helper to install Chocolatey ***
171+ function InstallChocolatey (): String;
172+ var
173+ ResultCode: Integer;
174+ ChocoInstallScript: String;
175+ begin
176+ WizardForm.StatusLabel.Caption := ' Installing Chocolatey package manager...' ;
177+
178+ // Official Chocolatey install command
179+ ChocoInstallScript := ' Set-ExecutionPolicy Bypass -Scope Process -Force; ' +
180+ ' [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ' +
181+ ' iex ((New-Object System.Net.WebClient).DownloadString('' https://community.chocolatey.org/install.ps1'' ))' ;
182+
183+ // Run PowerShell with SW_SHOW to show the terminal to the user
184+ if not Exec(' powershell.exe' , ' -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "' + ChocoInstallScript + ' "' , ' ' , SW_SHOW, ewWaitUntilTerminated, ResultCode) then
185+ begin
186+ Result := ' Failed to launch PowerShell for Chocolatey installation. Code: ' + IntToStr(ResultCode);
187+ Exit;
188+ end ;
189+
190+ if ResultCode <> 0 then
191+ begin
192+ Result := ' Chocolatey installation failed. Code: ' + IntToStr(ResultCode);
193+ Exit;
194+ end ;
195+
196+ Result := ' ' ;
197+ end ;
198+
172199// Function to handle FFmpeg installation
173200function InstallFFmpeg (): String;
174201var
175202 ResultCode: Integer;
176203 FFmpegExePath: String;
204+ ChocoExePath: String;
205+ ChocoInstallResult: String;
177206begin
178207 InstalledFFmpeg := False;
208+
179209 // 1. Check if FFmpeg is already installed via PATH
180210 if Exec(ExpandConstant(' {cmd}' ), ' /C ffmpeg -version' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0 ) then
181211 begin
182212 Result := ' ' ; // Already installed, success
183213 Exit;
184214 end ;
185- // 2. If not, check if Chocolatey is installed
215+
216+ // 2. Check if Chocolatey is installed
186217 if not Exec(ExpandConstant(' {cmd}' ), ' /C choco -v' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode) or (ResultCode <> 0 ) then
187218 begin
188- // Choco is not installed. Inform the user.
189- MsgBox(' FFmpeg (a required dependency) is not installed.' + #13 #10 + #13 #10 +
190- ' This installer can use Chocolatey (choco) to install it, but choco was not found on your system.' + #13 #10 + #13 #10 +
191- ' Please install FFmpeg manually, or install Chocolatey and re-run this setup.' ,
192- mbInformation, MB_OK);
193- // Optional: Abort if FFmpeg is required (uncomment if needed)
194- // Result := 'FFmpeg installation required but Chocolatey not found.';
195- // Exit;
196- Result := ' ' ; // Don't abort setup, just inform
197- Exit;
219+ // *** MODIFICATION: Install Chocolatey if missing ***
220+ ChocoInstallResult := InstallChocolatey();
221+
222+ if ChocoInstallResult <> ' ' then
223+ begin
224+ // If Chocolatey failed to install, we can't proceed with FFmpeg
225+ Result := ChocoInstallResult;
226+ Exit;
227+ end ;
198228 end ;
199- // 3. Choco is installed, but FFmpeg is not. Install it.
200- // Show a marquee progress bar since choco can take a while
201- WizardForm.StatusLabel.Caption := ' Chocolatey is found. Installing FFmpeg (this may take a few minutes)...' ;
229+
230+ // 3. Choco is installed (or was just installed), install FFmpeg.
231+ WizardForm.StatusLabel.Caption := ' Installing FFmpeg via Chocolatey (this may take a few minutes)...' ;
202232 WizardForm.ProgressGauge.Style := npbstMarquee;
233+
203234 try
204- // Run choco install. Using SW_SHOW lets the user see choco's progress.
205- if not Exec(ExpandConstant(' {cmd}' ), ' /C choco install ffmpeg -y' , ' ' , SW_SHOW, ewWaitUntilTerminated, ResultCode) then
235+ // Determine path to choco. If we just installed it, it might not be in PATH yet for the installer process.
236+ // Try the standard install location first.
237+ ChocoExePath := ' C:\ProgramData\chocolatey\bin\choco.exe' ;
238+
239+ if FileExists(ChocoExePath) then
206240 begin
207- Result := ' Failed to launch Chocolatey to install FFmpeg. Code: ' + IntToStr(ResultCode);
208- Exit;
241+ // Use absolute path
242+ if not Exec(ChocoExePath, ' install ffmpeg -y' , ' ' , SW_SHOW, ewWaitUntilTerminated, ResultCode) then
243+ begin
244+ Result := ' Failed to launch Chocolatey (Absolute Path) to install FFmpeg. Code: ' + IntToStr(ResultCode);
245+ Exit;
246+ end ;
247+ end
248+ else
249+ begin
250+ // Fallback to global PATH
251+ if not Exec(ExpandConstant(' {cmd}' ), ' /C choco install ffmpeg -y' , ' ' , SW_SHOW, ewWaitUntilTerminated, ResultCode) then
252+ begin
253+ Result := ' Failed to launch Chocolatey (Global PATH) to install FFmpeg. Code: ' + IntToStr(ResultCode);
254+ Exit;
255+ end ;
209256 end ;
257+
210258 if ResultCode <> 0 then
211259 begin
212260 Result := ' Chocolatey failed to install FFmpeg. Code: ' + IntToStr(ResultCode);
213261 Exit;
214262 end ;
215263 finally
216- // Restore normal progress bar and clear status
217264 WizardForm.ProgressGauge.Style := npbstNormal;
218265 WizardForm.StatusLabel.Caption := ' ' ;
219266 end ;
220- // 4. Verify installation using full path (in case PATH not updated)
267+
268+ // 4. Verify installation using full path
221269 FFmpegExePath := ' C:\ProgramData\chocolatey\bin\ffmpeg.exe' ;
222270 if not FileExists(FFmpegExePath) then
223271 begin
224272 Result := ' FFmpeg installed but executable not found in expected path.' ;
225273 Exit;
226274 end ;
275+
227276 if not Exec(FFmpegExePath, ' -version' , ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode) or (ResultCode <> 0 ) then
228277 begin
229278 Result := ' FFmpeg installed but -version failed even with full path. Code: ' + IntToStr(ResultCode);
@@ -250,7 +299,8 @@ begin
250299 Result := PandocResult; // Return Pandoc error
251300 Exit;
252301 end ;
253- // Second, check/install FFmpeg
302+
303+ // Second, check/install FFmpeg (and Choco if needed)
254304 FFmpegResult := InstallFFmpeg();
255305 if FFmpegResult <> ' ' then
256306 begin
0 commit comments