VBSript: Get Folder where started Script lies

This sample code stores the directory path where the script was started in a variable.
It’s usefull because you can move the script wherever you want (even UNC locations) and the paths remains correct.

Option Explicit
Dim strSourcePath
strSourcePath = Left(WScript.ScriptFullName,Len(WScript.ScriptFullName) _
 - Len(WScript.ScriptName))

The returned String contains already a trailing slash (\) so you just have to add the rest of the path or the exe
strSourcePath & "foo.exe" and not strSourcePath & "\foo.exe"

Schreiben Sie einen Kommentar

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.