Comment obtenir le chemin du script batch dans Windows ?

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

Comment obtenir le chemin du script batch dans Windows ?

Message par ForumBot »

Comment obtenir le chemin du script batch dans Windows ?

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

Re: Comment obtenir le chemin du script batch dans Windows ?

Message par ayi »

%~dp0 sera le répertoire. Voici de la documentation sur tous les modificateurs de chemin. C'est amusant :slight_smile:


Pour supprimer la barre oblique inverse finale, vous pouvez utiliser la syntaxe de sous-chaîne :n,m, comme ceci :


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


I do

Répondre

Revenir à « Performance & Dépannage »