run script from STDIN

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
lazna
Posts: 62
Joined: 27 Dec 2012 10:54

run script from STDIN

#1 Post by lazna » 04 Jan 2022 05:34

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?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: run script from STDIN

#2 Post by aGerman » 04 Jan 2022 10:40

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

Post Reply