As mentioned here, the old-school method to run another script is by using temporary files. Simple
echo it into a file and then run it(and remove it optionally).
Here's the basic concept:
@echo off echo //A JS Comment > TempJS.js echo //Add your code>>TempJS.js cscript //nologo //e:cscript.exe TempJS.js del /f /s /q TempJS.js
But this would require lots of
echo statements to create a relatively large JScript. Here's a better method by Aacini.
@echo off setlocal rem Get the number of the "<resource>" line for /F "delims=:" %%a in ('findstr /N "<resource>" "%~F0"') do set "start=%%a" rem Skip such number of lines and show the rest of this file (for /F "usebackq skip=%start% delims=" %%a in ("%~F0") do echo %%a) > TempJS.js cscript //nologo //e:cscript.txt TempJS.js del /f /s /q TempJS.js goto :EOF <resource> JScript JScript JScript