日期:2008-11-09  浏览次数:20957 次

'*************************************************
' file:   CurrentDir.vbs (WSH sample in VBScript)

' Autor:  (c) G. Born
'
' Retrieving the current directory
'*************************************************
Option Explicit

WScript.Echo "Script Path: ", GetPath(), vbCrLf, _
             "Current Directory: ", CurrentDir()

WScript.Quit  ' Terminate script.

Function CurrentDir
    Dim fso
    Set fso = WScript.CreateObject("Scripting.FileSystemObject")
    CurrentDir = fso.GetAbsolutePathName(".")
End Function

Function GetPath
    ' Retrieve path to the script file
    Dim path
    path = WScript.ScriptFullName  ' Script file name
    GetPath = Left(path, InstrRev(path, "\"))
End Function

'*** End