Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

[SCRIPTING] Cheat: where am i?

Publié le par damcuvelier

if you want to use something in the folder of your script, but you don't know what will be the path of your script when it will be run, use:

VBSCRIPT or VBA: here=left(WScript.ScriptFullName,len(WScript.ScriptFullName)-len(WScript.ScriptName)-1) & "\"
this in batch:     %here%=%~dp0 (the "\" is in the variable, good is %~dp0toto.txt not %~dp0\toto.txt)

 

Powershell:

$here = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)

Commenter cet article