1

I would like to run my batch script from anywhere, for example:

C:\>test123

And that command line executes my batch script C:\Documents\test123.bat.

I tried to do it with environment variable path, but it doesn't seem to work.

Mofi
  • 46,139
  • 17
  • 80
  • 143
Jakov Gl.
  • 361
  • 3
  • 11
  • 1
    Does this answer your question? [Add batch file to PATH](https://stackoverflow.com/questions/28574800/add-batch-file-to-path) – Marwan N Feb 16 '20 at 16:26
  • 1
    After you add a directory to your path you have to exit the cmd window and start a new one because the old one still has the old path. – Marichyasana Feb 16 '20 at 16:52

2 Answers2

3

Add your bat to PATH and make sure PATHEXT contains .BAT

How to add your program to the PATH env variable

Note, that the current working directory will be whereever you called it from. If you want relative paths to where the bat is stored, use %~dp0

Please post the output of echo %PATHEXT% %PATH% and tell us the exact location of your bat file and more error info why it failed in your case?

5andr0
  • 1,578
  • 1
  • 18
  • 25
0

Adding to C:\Windows\System32

Worked for Me.

System info: Windows 10 with Admin access.

Ayush Pal
  • 154
  • 3
  • 8