Page 1 of 1

run script from STDIN

Posted: 04 Jan 2022 05:34
by lazna
Is there any way to run batch from STDIN/pipe? In linux, there is a possibility to run scripts without save it to disc first:

Code: Select all

curl http://exmaple.com/run.sh |sudo bash
Is something similar possible with batch files?

Re: run script from STDIN

Posted: 04 Jan 2022 10:40
by aGerman
It's possible. However, cmd.exe is going to use command-line-mode rather than script-mode in this case.

Code: Select all

type "script.txt" | cmd
This will execute the content of "script.txt" the same way as writing it line by line into a cmd prompt.

Steffen