I have created a Basic MSI project and in that I have written a InstallScript Custom Action to download a file from server. I used CopyFile()
function for this. I'm also showing sdShowMsg()
during this download. But when the download server is not responsive, sdShowMsg()
dialog stay as it is on the screen and in the background download, does not happen. So is there any way to add a countdown timer, which will perform the download operation for that period of time only and then exit from it. Or is there any other way to check first if the download server is responsive or not ?
SdShowMsg("Please Wait... Downloading file from our server...", TRUE);
CopyFile("https://<downloadURL>/sample.rtf", szEULAFile);
SdShowMsg("Please Wait... Downloading file from our server...", FALSE);
You could replace the CopyFile call with an external command to download files and then use the LaunchApp() function, setting a timeout. Here is a small pseudo-example using powershell (you can also use curl.exe and many other methods to download files from command line)
nOptions = LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN | LAAW_OPTION_FIXUP_PROGRAM | LAAW_OPTION_SHOW_HOURGLASS;
LAAW_PARAMETERS.nTimeOut = 30000; // 30 seconds
SdShowMsg("Downloading, please wait...", TRUE);
nResult = LaunchAppAndWait( "powershell", "-Command \"Invoke-WebRequest -Uri https://example.com/sample.rtf -OutFile " + szEULAFile + "\"", nOptions);
SdShowMsg("", FALSE);
if nResult < 0 then
// failed to launch, notify the user
elseif (nResult == 5) || (nResult == 259) then
// timeout reached, notify the user
endif;