也许是好东西——Windows Script Host-4[获取当前目录]

发表于:2007-06-30来源:作者:点击数: 标签:
‘’************************************************* ‘’ File:CurrentDir. vb s (WSH sample in VB Script) ‘’ Autor:(c) G. Born ‘’ ‘’ Retrieving the current directory ‘’************************************************* Option Explic
‘’*************************************************
‘’ 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

原文转自:http://www.ltesting.net