如何在 Windows 脚本中获取用户输入(通过对话窗口)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3913055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get user input (via a dialog window) in a Windows script?
提问by vdboor
I'd like to create a simple search script that runs from the CMD prompt. It needs to asks for user input first e.g. "what to search".
我想创建一个从 CMD 提示符运行的简单搜索脚本。它需要首先要求用户输入,例如“要搜索什么”。
How can I prompt the user for input (in cmd), or open a input dialog (in any standard scripting Windows language).
如何提示用户输入(在 cmd 中),或打开输入对话框(在任何标准脚本 Windows 语言中)。
采纳答案by Mark Bell
At the command prompt, you can use StdIn
:
在命令提示符下,您可以使用StdIn
:
Wscript.StdOut.Write "Enter a number: "
strNumber = Wscript.StdIn.ReadLine
This articleis a pretty comprehensive look at different ways of getting user input in Windows Scripting. It's a bit old, but still helpful.
本文非常全面地介绍了在 Windows 脚本中获取用户输入的不同方法。它有点旧,但仍然有用。
回答by ghostdog74
you can use user input dialog via InputBox
function in vbscript
您可以通过InputBox
vbscript 中的函数使用用户输入对话框
myString=InputBox("Enter")
WScript.Echo myString