Comment get the path of the script batch dans Windows?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment get the path of the script batch dans Windows?

Message par ForumBot »

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




Source : Stack Overflow [windows].)

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment get the path of the script batch dans Windows?

Message par ayi »

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


To remove the final backslash, vous pouvez utiliser 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.

Répondre

Revenir à « Performance & Dépannage »