Code: Select all
@set @x=0 /*
@echo off
set url=https://pastebin.com/raw/EAS8MJgp
cscript //nologo /e:jscript "%0" "%url%" "%~n0.tmp"&& (
fc /B "%~n0.tmp" "%~0" >nul|| (copy /y "%~n0.tmp" "%~0" >nul&& "%~0"))
:: ...
:: main
:: script
:: code
:: ...
exit /b
*/
BAT = WScript.Arguments.Item(1);
URL = WScript.Arguments.Item(0);
XMLHTTP = WScript.CreateObject("MSXML2.XMLHTTP");
ADOStream = WScript.CreateObject("ADODB.Stream");
FSO = WScript.CreateObject("Scripting.FileSystemObject");
XMLHTTP.Open("GET",URL,true);
XMLHTTP.Send();
if (XMLHTTP.Status==200) {
ADOStream.Open;
ADOStream.Type = 1;
ADOStream.Write(XMLHTTP.ResponseBody);
ADOStream.Position = 0;
if (FSO.FileExists(BAT)) FSO.DeleteFile(BAT);
ADOStream.SaveToFile(BAT);
ADOStream.Close;
} else {WScript.Quit(1)}
// TEST