WScriptオブジェクトの簡単ラッパーオブジェクト
WScript.exeやCScript.exeのWScriptオブジェクトをVBやVBAから使うには、そのラッパオブジェクトを作ればよいのです。
まぁそこまでしなくても、手抜きのラッパーオブジェクト擬似なら簡単です。
WScript.VBS
---
Do While Not WScript.StdIn.AtEndOfStream
Execute WScript.StdIn.ReadLine
Loop
---
WScript.exeを使うには、
Set wShell=CreateObject("WScript.Shell")
Set oExec=wShell.Exec("WScript.exe WScript.VBS")
oExec.StdIn.WriteLine "WScript.Echo 5000"
oExec.StdIn.WriteLine "WScript.Sleep 5000"
oExec.StdIn.WriteLine "WScript.Echo 5000"
oExec.StdIn.Close
CScript.exeを使うには、
Set wShell=CreateObject("WScript.Shell")
Set oExec=wShell.Exec("CMD /C CScript.exe WScript.VBS >CON")
oExec.StdIn.WriteLine "WScript.Echo 5000"
oExec.StdIn.WriteLine "WScript.Sleep 5000"
oExec.StdIn.WriteLine "MsgBox 5000"
oExec.StdIn.Close
« IsEmpty() などは使わないこと。 | トップページ | .NETでファイルを検索するときは、Directory.GetFiles(,検索パターン)を積極的に使うべし。 »