2011年9月29日木曜日

Scriptファイルの絶対パス

WScript.ScriptFullName

実行しているスクリプトのフルパスを得られる。

【例】
 FullPath = WScript.ScriptFullName
 CurrentDir = Left(FullPath ,InStrRev(FullPath ,"\"))

末尾に\が付いている。

【例-1】
MsgBox CreateObject("Scripting.FileSystemObject").GetFolder(".").Path

【例-2】
MsgBox CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)

【例-3:CurrentDrive】
msgbox CreateObject("Scripting.FileSystemObject").GetDriveName(WScript.ScriptFullName)