embed Javascript in .bat files

前端 未结 8 1908
旧巷少年郎
旧巷少年郎 2020-12-29 17:06

Is ther any way to execute javascript from a .bat file or embed the javascript in .bat file.

I need a javascript code to write/read to a file in a local folder.This

8条回答
  •  星月不相逢
    2020-12-29 17:28

    You can run a JScript script from a batch-file with the command-line based scripting host CScript.exe.

    You would need the script in a separate file though which you pass as an argument to CScript.exe. If you want to keep everything in a single file, you can embed the JScript code in you batch-file, dump it to a temporary file which you pass to CScript.exe and delete the temporary script file afterwards.

    There might be more elegant solutions (hopefully)

提交回复
热议问题