如何启动VBS的交互式控制台? [英] How can I start an interactive console for VBS?

查看:143
本文介绍了如何启动VBS的交互式控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与这个问题非常相似:

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

我只是想开始输入VBS语句,一次一次,并立即对其进行评估,例如Python的IDLE。

I just want to be able to start entering VBS statements, one at a time, and have them evaluated straight away, like Python's IDLE.

推荐答案

我写了。它基于此博客文章(已存档此处),但带有几个增强功能。本质上,它是使用 <$ c的REPL(读取,执行,打印,循环) $ c> Execute 语句:

I wrote this a couple years ago. It's based on this blog post (archived here), but with a couple enhancements. Essentially it's a REPL (Read, Execute, Print, Loop) using the Execute statement:

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)开始,例如:

I usually start it with a batch file of the same name (i.e. "vbs.vbs" and "vbs.bat"), like this:

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

这篇关于如何启动VBS的交互式控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆