Jayjar291
Jayjar291

Reputation: 22

Use cmd to run batch code

Hi I need to run a file witch contains batch code from cmd and is not a batch file.

I have tested cmd < test.bob
and it gets one line in and ends

I did this before but I don't remember the code i think it was cmd /v:on < test.bob
or cmd /E:on < test.bob
please help me

note please don't tell me to change the extension

Upvotes: 0

Views: 150

Answers (1)

Aacini
Aacini

Reputation: 67216

You can do that this way:

cmd < test.bob

If you use Delayed Expansion in your "Not Batch file", use this:

cmd /V:ON < test.bob

However, there are several differences that apply to the "Not Batch file"; the most important one is that the following Batch file features don't works in the "Not Batch file":

  • Access to Batch file parameters via %1 %2 ... and execution of SHIFT command.
  • Execution of GOTO command.
  • Execution of CALL :NAME command (internal subroutine).
  • Execution of SETLOCAL/ENDLOCAL commands.

The complete description of the way to do this ("Execute a text file with no .BAT extension as a Batch file") is described at this post, with examples and recommendations.

Upvotes: 1

Related Questions