Nadie se iba a imaginar que se había cambiado la aplicación por defecto del archivo VBS
No te olvides de dejar la línea como estaba para que al terminar borre ese archivo temporal.
Code: Select all
w '%output{' + InstallerPath + curlOutputTmp + '}Download completed with response code %{http_code}\n'
Code: Select all
if (fileExists(InstallerPath + curlOutput)) then
DeleteFile(InstallerPath + curlOutput);
curlOutputTmp := curlOutput + '.tmp';
if (fileExists(InstallerPath + curlOutputTmp)) then
DeleteFile(InstallerPath + curlOutputTmp);
sCommand := '-L -w "%output{' + InstallerPath + curlOutputTmp + '}Download completed with response code %{http_code}\n" --output "' + InstallerPath + curlOutput + '" --url "' + address + '" ' + '-H "Accept: text/html, */*" -H "Accept-Language: it" -H "DNT: 1" -H "Priority: u=0, i" -H "Sec-Ch-Ua: \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"" -H "Sec-Ch-Ua-Mobile: ?0" -H "Sec-Ch-Ua-Platform: \"Windows\"" -H "Sec-Fetch-Dest: Document" -H "Sec-Fetch-Mode: Navigate" -H "Sec-Fetch-Site: None" -H "Sec-Fetch-User: ?1" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: ' + curlUserAgent + '"';
Sleep(delayBetweenRequest);
Launch(curlPath, sCommand);
cnt := 0;
while ((not FileExists(InstallerPath + curlOutputTmp)) AND (cnt < 200)) Do
begin
cnt := cnt + 1;
Sleep(50);
end;
DeleteFile(InstallerPath + curlOutputTmp);
if (fileExists(InstallerPath + curlOutput)) then
begin
fileContent := TStringList.Create;
fileContent.LoadFromFile(InstallerPath + curlOutput);
[...]
Code: Select all
Launch('wscript.exe', InstallerPath + vbsScript);
I'm not 100% sure curl lock the file (we should double check), that's why I created tmp file. Before the tmp file, my ifs was something like this:Garada wrote: 2025-08-16 18:55:25 Good idea but I'm not sure it's necessary.
CURL should create/open the file for writing and keep it locked until it is closed.
While the file is locked it can't be renamed (MoveFile function), so wait for MoveFile function return success should be a good indicator that the process is complete.
Have you had trimmed results with the HTML file generated by CURL? If so, then all previous paragraph is useless.![]()
Code: Select all
while ((not FileExists(InstallerPath + curlOutput)) do Sleep(50);
fileContent := TStringList.Create;
fileContent.LoadFromFile(InstallerPath + curlOutput);
Code: Select all
# USE A HUGE FILE TO DOWNLOAD
# CHANGE X:\C.ts WITH YOUR PATH
$job = Start-Job {
curl.exe -L 'http://PUT HERE A URL FOR A BIG FILE' --output 'X:\C.ts'
}
# CHANGE X:\C.ts WITH YOUR PATH
while (-not (Test-Path "X:\C.ts")) {
Start-Sleep -Milliseconds 50
}
# CHANGE X:\C.ts WITH YOUR PATH
if ($job.State -eq 'Running') {
try {
$fs = [System.IO.File]::Open("X:\C.ts", 'Open', 'Read', 'ReadWrite')
Write-Host "File Not Locked."
$fs.Close()
}
catch {
Write-Host "File Locked."
}
}
$job | Wait-Job | Remove-Job
It's up to your connection, your pc and how busy is the server. With a slow connection you could have problems and get a blank page.Garada wrote: 2025-08-16 18:55:25 But I've made some tests checking the result is complete (looking for the end tag "</html>") and all of them were correct.
In my first test with your script it worked as you said. But in other tests it starts opening and closing dozens of time and every time I cannot minimize or put another window upon. I don't know why.Garada wrote: 2025-08-16 18:55:25 And yes, +1 for an udpated version of Launch function with a parameter to hide the program executed.
BTW, on my system, the terminal icon briefly appears in the taskbar but not the entire window on the desktop. I mean, it runs minimized, Is that the case for you?
Great!Garada wrote: 2025-08-16 19:05:03 NOTE 2:
To avoid problems such as PACOIRIPO's, I would change the way the VBS file is executed.
Try this (not tested):Code: Select all
Launch('wscript.exe', InstallerPath + vbsScript);