VBscript relative path

前端 未结 2 2369
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 13:26

I\'m trying to use the following script (It\'s being called by a Batch file, by the way) to unzip files in Windows XP:

strZipFile =\"C:\\test.zip\"                   


        
相关标签:
2条回答
  • 2020-12-19 14:03

    This should get you the zip file's full path:

    strZipFile ="test.zip" 
    dim fso, fullPathToZip
    set fso = CreateObject("Scripting.FileSystemObject")
    fullPathToZip = fso.GetAbsolutePathName(strZipFile)
    
    0 讨论(0)
  • 2020-12-19 14:20

    WScript.ScriptFullName and FSO.GetParentFolder should solve your problem:

    >> p = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
    >>
    >> WScript.Echo p
    >>
    M:\bin
    

    Update wrt Kiril's comment:

    Evidence for the answer "Yes":

    Option Explicit
    
    Class cX
      Private Sub Class_Initialize()
        WScript.Echo "Class_Initialize"
      End Sub
      Private Sub Class_Terminate()
        WScript.Echo "Class_Terminate"
      End Sub
      Public Function f()
        f = "qed"
      End Function
    End Class
    
    WScript.Echo 1
    Dim f : f = (New cX).f()
    WScript.Echo 2
    WScript.Echo f
    

    output:

    cscript 15621395.vbs
    1
    Class_Initialize
    Class_Terminate
    2
    qed
    
    0 讨论(0)
提交回复
热议问题