Getting current directory in VBScript

后端 未结 7 2361
天命终不由人
天命终不由人 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:27

    Your line

    Directory = CurrentDirectory\attribute.exe
    

    does not match any feature I have encountered in a vbscript instruction manual. The following works for me, tho not sure what/where you expect "attribute.exe" to reside.

    dim fso
    dim curDir
    dim WinScriptHost
    set fso = CreateObject("Scripting.FileSystemObject")
    curDir = fso.GetAbsolutePathName(".")
    set fso = nothing
    Set WinScriptHost = CreateObject("WScript.Shell")
    WinScriptHost.Run curDir & "\testme.bat", 1
    set WinScriptHost = nothing
    

提交回复
热议问题