I have made a basic BAT script to download updates from Avast virus database and then apply them by running the downloaded file.
@ECHO OFF
set downloadFolder=C:\Users\myuser\Downloads\Avast_updates
set downloadUrl=https://install.avcdn.net/vps18/vpsupd.exe
bitsadmin /transfer myAvastUpdates /download /priority normal ^
"%downloadUrl%" "%downloadFolder%\vpsupd.exe"
start /min "Update..." "%downloadFolder%\vpsupd.exe"
exit
Also, I have created a Windows task to run BAT every x hours.
Everything works correctly, but I want to know if there is any way to automatically close the executable window after the update process is finished.
It occurred to me to use TASKILL after x seconds, but that doesn't assure me that the update process finished in x seconds, sometimes it can take longer and sometimes less, plus I don't want to use that command in an program security installer.
Then it occurred to me to send an "Enter" through WshShell.SendKeys:
set SendKeys=CScript //nologo //E:JScript "%~F0"
cls
timeout /t 5 >nul
%SendKeys% "{ENTER}"
@end
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
But it did not work because that window does not close with "Enter" nor "ALT F4", it closes only if we click on "Done" or on the cross "x" to close the window (if it worked it would have the problem of setting the time again).
Is there a way to automatically close that window once the update process finishes?
