与这个问题非常相似:
如何启动 Perl 的交互式控制台? https://stackoverflow.com/questions/73667/how-can-i-start-an-interactive-console-for-perl
我只是希望能够开始输入 VBS 语句,一次一个,并立即对它们进行评估,就像 Python 的 IDLE 一样。
I wrote this http://www.planetcobalt.net/sdb/vbsh.shtml几年前。它基于这篇博文 http://www.kryogenix.org/days/2004/04/01/interactiveVbscript(已存档here https://web.archive.org/web/20040405070027/http://www.kryogenix.org/days/2004/04/01/interactiveVbscript),但有一些增强功能。本质上它是一个 REPL(读取、执行、打印、循环),使用Execute https://msdn.microsoft.com/en-us/library/03t418d2.aspx陈述:
If Not LCase( Right( WScript.FullName, 12 ) ) = "\cscript.exe" Then
For Each Arg In WScript.Arguments
If InStr( Arg, " " ) Then Arg = """" & Arg & """"
Str = Str & " " & Arg
Next
WshShell.Run "cscript """ & WScript.ScriptFullName & """" & Str, 1
WScript.Quit
End If
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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)