如何为VBS启动交互式控制台?

问题描述 投票:4回答:2

与此问题非常相似:

How can I start an interactive console for Perl?

我只是希望能够一次开始输入VBS语句,并立即对它们进行评估,比如Python的IDLE。

vbscript console interpreter interactive read-eval-print-loop
2个回答
5
投票

我几年前写过this。它基于this blog post(存档的here),但有几个增强功能。基本上它是使用Execute语句的REPL(读取,执行,打印,循环):

Do While True
    WScript.StdOut.Write(">>> ")

    line = Trim(WScript.StdIn.ReadLine)

    If LCase(line) = "exit" Then Exit Do

    On Error Resume Next
    Execute line
    If Err.Number <> 0 Then
        WScript.StdErr.WriteLine Err.Description
    End If
    On Error Goto 0
Loop

我通常用一个同名的批处理文件(即“vbs.vbs”和“vbs.bat”)启动它,如下所示:

@cscript.exe //NoLogo %~dpn0.vbs

0
投票

您可以尝试让调试器(cscript //X your.vbs)为您工作,或者启动您自己的项目 - 也许基于these (first 3?) proposals

© www.soinside.com 2019 - 2024. All rights reserved.