vbscript
Windows スクリプト ファイル (.wsf) を使用する
外部ファイルのインクルード
以下のようにすることで外部ファイルをインクルードすることができます。
* 準備
Const ForReading = 1 Dim FileShell Set FileShell = WScript.CreateObject("Scripting.FileSystemObject") Function ReadFile(ByVal FileName) ReadFile = FileShell.OpenTextFile(FileName, ForReading, False).ReadAll() End Function
- インクルード例
' グローバルに使用したい場合
Execute ReadFile("stdlib.vbs") Function HogeCalculate(ByVal ...) ' 関数( Function or Sub )内でのみ使用したい場合 Execute ReadFile("mathlib.vbs") ... End Function GetFreeSpace? † function GetFreeSpace(drvPath) { var fs, d, s; fs = new ActiveXObject("Scripting.FileSystemObject"); d = fs.GetDrive(fs.GetDriveName(drvPath)); s = "Drive " + drvPath + " - " ; s += d.VolumeName; s += " Free Space: " + d.FreeSpace/1024 + " Kbytes"; return s; }
vbscript.txt · 最終更新: 2019/06/30 12:22 by 127.0.0.1