How to DIRECTLY execute a command in a txt file in cmd?

I have a question.

How to execute a command in a text file?

I know this is crazy, and I can just rename it as a .bat file, but for me it is important.
Without renaming it, can I execute it in CMD?

I know that I can just do this:

ren command.txt command.bat & call command.bat & ren command.bat command.txt

But this is too inconvenient. Any easier way?

+3
source share
2 answers
cmd < command.txt

Of course, this depends on the actual contents of command.txt.

+5
source
FOR /F "tokens=*" %%* IN (command.txt) DO %%*
0
source

All Articles