How to get the path of the batch script in Windows?

%~dp0 will be the directory. Here’s some documentation on all of the path modifiers. Fun stuff 🙂

To remove the final backslash, you can use the :n,m substring syntax, like so:

SET mypath=%~dp0
echo %mypath:~0,-1%

I don’t believe there’s a way to combine the %0 syntax with the :~n,m syntax, unfortunately.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)