The documentation for DownloadTemporaryFile
says this about the RequiredSHA256OfFile
parameter:
If
RequiredSHA256OfFile
is set it will compare this to the SHA-256 of the downloaded file and raise an exception if the hashes don't match.An exception will be raised if there was an error. Otherwise, returns the number of bytes downloaded. Returns 0 if
RequiredSHA256OfFile
is set and the file was already downloaded.
From the answer here I have determined that the correct commandline method to obtain the checksum is:
CertUtil -hashfile MSAHelpDocumentationSetup.exe SHA256
This is how I add adding this particular file to my script:
AddFileForDownload('{#HelpDocSetupURL}', 'HelpDocSetup.exe');
Which expands to:
procedure AddFileForDownload(Url, FileName: string);
begin
DownloadPage.Add(Url, FileName, '');
FilesToDownload := FilesToDownload + ' ' + ExtractFileName(FileName) + #13#10;
Log('File to download: ' + Url);
end;
Is there way to automate:
- Obtaining the checksum for my file.
- Caching that checksum into a string.
- Using that checksum value when building the script.
By automating this task it will provide two benefits:
- Minimize user error in copy /pasting the checksum value.
- Keep the checksum update to date without user interaction.
Is this feasible in Inno Setup with Pascal Script?
Pascal Script won't help you. You need the value at the compile time. So using a preprocessor. You can indeed execute the
certutil
. But imo, in this case, it's easier to use PowerShell and itsGet-FileHash
cmdlet:And then you can use it like:
You of course need to add the third parameter to your
AddFileForDownload
function and pass it toTDownloadWizardPage.Add
. You also may need to add a path to the file, so that the preprocessor can find it.