Run a Text File as a Batch Script
Yes this is possible by making the text file which contains the commands you need executed to be referenced as the first batch argument that is passed to the batch script.
You can set the argument value as a variable and using type you can create a temporary batch file with the content of the text file and then run that file through cmd to process accordingly.
Batch Script Logic
if exist "%tmp%\%cName%.cmd" del /q /f "%tmp%\%cName%.cmd"
if not exist "%tmp%\%cName%.cmd" type "%cmdtxt%" >> "%tmp%\%cName%.cmd"
cmd /k "%tmp%\%cName%.cmd"
Note: You can use cmd /c to have the command window(s) close after execution.
ECHO Line 1
Note: This is the text file without a
.cmd which each line will contain a valid batch command which will be executed.
Execute this by using either. . .
1.Drag and Drop
2. Command Line
@ECHO OFF Results