08.02.2022 Views

batch-file-es Windows

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Como se mencionó aquí , el método de la vieja escuela para ejecutar otro script es mediante el

uso de archivos temporales. Simplemente haga echo en un archivo y luego ejecútelo (y elimínelo

opcionalmente).

Aquí está el concepto básico:

@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

Pero esto requeriría muchas declaraciones de echo para crear un JScript relativamente grande.

Aquí hay un método mejor por 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

Lea Híbridos por lotes y JSCript en línea: https://riptutorial.com/es/batch-file/topic/10578/hibridospor-lotes-y-jscript

https://riptutorial.com/es/home 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!