I can't find any way to do, for example, the following:
cmd.exe /C "script.txt"
In other words, I need Command Prompt to (try) to execute file with any extension (not necessarily .bat
or .cmd
) if it contains valid batch script code. I'm looking for behavior similar to Unix shells:
./script.txt
While on Unix the shebang (#!/bin/sh
) is responsible for understanding that the file is actually a script, it seems like on Windows .bat
or .cmd
extensions play the same role, indicating a batch script file for Command Prompt.
Is it possible to avoid that and force Command Prompt to interpret a file with any name?
NOTE: Please, no answers like:
Give your file
.bat
or.cmd
extension.
That's not what the question is about.
This depends on the complexity of the NON-Batch file. If the NON-Batch file does not use these facilities:
then you may execute any file as a "Batch file" via this trick:
cmd < anyFile.ext
Further details at this post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With