Put this bit in peval.vbs
Dim StdIn, script script = "" Set StdIn = WScript.StdIn Do While Not StdIn.AtEndOfStream script = script + vbNewLine + StdIn.ReadLine Loop execute script
And here's how to use it:
var = test script = ( Dim s s = "%var%" WScript.echo "Hi there, " & s ) F1:: text := RunVBS(script) Msgbox, %text% return ;CMDRet functions RunWaitEx(CMD, CMDdir, CMDin, ByRef CMDout, ByRef CMDerr) { VarSetCapacity(CMDOut, 100000) VarSetCapacity(CMDerr, 100000) RetVal := DllCall("cmdret.dll\RunWEx", "str", CMD, "str", CMDdir, "str", CMDin, "str", CMDout, "str", CMDerr) Return, %RetVal% } Capture(CMD, input) { CMDOUT = CMDERR = RunWaitEx(CMD, a_scriptdir, input, CMDOUT, CMDERR) return %CMDOUT% } ;let's run some vbscript stuff RunVBS(script) { return Capture("cscript.exe peval.vbs",script) }
You obviously need CMDRet to make this work. The peval.vbs (peval is short for pipe-eval) script gives you the ability to pipe scripts into cscript or wscript, like you can with perl, python, or just about any other scripting language. So just stick the RunVBS function in some file to be included, along with the CMDRet functions and you can just use RunVBS whenever.
Enjoy. Let me know if you find any weird behavior or possible improvements.