How to call a .bat file from any location in CMD on Windows How to call a .bat file from any location in CMD on Windows windows windows

How to call a .bat file from any location in CMD on Windows


Set that location in your PATH environmental variable.

I wouldn't put it the root or the system directory.

I keep a directory with all my scripts in C:\DRR\CMD

and either set it in the MyComputer GUI or run at the command script:

set PATH=%PATH%;C:\DRR\CMD


You could just put it in your c:\windows\system32 directory, as its always in the system path.


How about..."%MyBatch%"? (the double qoutes are intended)

That should work!

to change your Variable, use set MyBatch="Path\Whatever.bat"

and to ask the user for a String, use set /p MyBatch="Question? "
-- or, you can use a BAT-to-EXE converter to run the batch in a Executable.