6

I have a question.

How can I execute command in a plain text file?

I know it seems crazy and I can simply rename it as a .bat file BUT it is important for me.
Without renaming it, can i execute it in CMD?

I know I can simply do this :

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

But this is too inconvenient. Any simpler way?

2 Answers 2

15
cmd < command.txt

Of course it depends of the real content of command.txt.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.