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.
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?
Adding to C:\Windows\System32
Worked for Me.
System info: Windows 10 with Admin access.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.