Getting current directory in VBScript

后端 未结 7 2363
天命终不由人
天命终不由人 2020-11-29 02:45

I\'m trying to get the current directory and use it to run an application no matter where the file is put and no matter how the path is changed

Dim fso: set          


        
相关标签:
7条回答
  • 2020-11-29 03:33

    You can use WScript.ScriptFullName which will return the full path of the executing script.


    You can then use string manipulation (jscript example) :

    scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1)
    


    Or get help from FileSystemObject, (vbscript example) :

    scriptdir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
    
    0 讨论(0)
提交回复
热议问题