Current Path Retrieval in DOS Script
Solved/Closed
denis
-
pate de canard -
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é.
```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 answers
-
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% -
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 -
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.
-
Could you clarify because as it's explained, it's a bit vague ;-)
I don't see the point.
Thank you.