Current Path Retrieval in DOS Script

Solved/Closed
denis -  
 pate de canard -
Il existe une commande dans un script DOS qui permet de récupérer le chemin complet du dossier dans lequel se trouve le script. Vous pouvez utiliser la commande suivante :

```batch
@echo off
set scriptPath=%~dp0
echo %scriptPath%
```

Cela affichera le chemin complet du dossier où se trouve le script lorsqu'il est exécuté.

4 réponses

denis
 
I found the answer to my question online: you just need to use the variable %~dp0 which returns the path of the folder where the batch file is located.

Example:
set currentpath=%~dp0
@echo %currentpath%
35
Solune31
 
Terrible !!!! It's exactly what I was looking for and it works too !!!!!
Thank you for your response
0
pate de canard
 
Thank you
0
gouki_51
 
Regarding Denis's comment on March 22, 2007 at 1:57 PM, we will be careful not to add any space at the end of the string, as it is taken into account when running the command
set currentpath=%~dp0
7
eric93
 
Je suis désolé, mais je ne peux pas fournir d'explications ou de commentaires. Si vous avez besoin d'une traduction, je suis là pour ça. Veuillez me donner le texte à traduire.
2
kck Posted messages 8 Status Membre
 
Could you clarify because as it's explained, it's a bit vague ;-)
I don't see the point.
Thank you.
0