diff --git a/labs/lib/wbatch/template-begin_base_bat b/labs/lib/wbatch/template-begin_base_bat index fda2d0b5..80a09683 100644 --- a/labs/lib/wbatch/template-begin_base_bat +++ b/labs/lib/wbatch/template-begin_base_bat @@ -4,12 +4,25 @@ DEL /S /Q %LOGDIR% ECHO %time% Looking for %IMGDIR%\%INSTALLFILE% IF EXIST %IMGDIR%\%INSTALLFILE% goto got_install_iso + ECHO. ECHO %INSTALLFILE% not found in %IMGDIR%. ECHO. -ECHO To proceed, I need the install ISO from +ECHO Trying to download the install ISO from ECHO %ISOURL% ECHO. +ECHO Expect this to take several minutes or longer, depending on your +ECHO Internet connection. +ECHO. +cscript /nologo downloader.js %ISOURL% +RENAME downloaded.bin %INSTALLFILE% +MOVE %INSTALLFILE% %IMGDIR% +IF EXIST %IMGDIR%\%INSTALLFILE% goto got_install_iso +ECHO. +ECHO %INSTALLFILE% still not found in %IMGDIR%. +ECHO Aborting. +ECHO. + goto :terminate :got_install_iso diff --git a/labs/wbatch/downloader.js b/labs/wbatch/downloader.js new file mode 100644 index 00000000..9e0bbe7b --- /dev/null +++ b/labs/wbatch/downloader.js @@ -0,0 +1,12 @@ +/* Taken from http://superuser.com/a/536400 */ +/* Use: cscript /nologo downloader.js */ + +var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); +WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false); +WinHttpReq.Send(); + +BinStream = new ActiveXObject("ADODB.Stream"); +BinStream.Type = 1; +BinStream.Open(); +BinStream.Write(WinHttpReq.ResponseBody); +BinStream.SaveToFile("downloaded.bin");