Download remote file into memory via pure batch

Download and execute without a temporary file

curl -s https://example.com/test.bat | cmd /v:on /k

Example test.bat

@echo off
(
cls

echo Hello
echo Time: !time!
exit
)

Building the code

As said in Force batch file to load to RAM before running you can cache a single command block.

There are some limitations:

  • It's running in cmd (not batch) context, variable expansion is a bit different.
  • Labels can't be used

With this technique you can use the normal batch macro style.