Getting current directory in VBScript

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

    Use With in the code.

    Try this way :

    ''''Way 1
    
    currentdir=Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
    
    
    ''''Way 2
    
    With CreateObject("WScript.Shell")
    CurrentPath=.CurrentDirectory
    End With
    
    
    ''''Way 3
    
    With WSH
    CD=Replace(.ScriptFullName,.ScriptName,"")
    End With
    

提交回复
热议问题