窗口中提示输入 vbscript
我有一个在 xp 命令行上运行的 vbscript。它接受一个目录路径参数。有没有一种简单的方法可以在命令行框中提示用户这一点?
如果没有,我可以只回显传入的内容,以向用户显示他们实际输入的内容,以防出现拼写错误。
谢谢, James
Aftermath:
这是我最终得到的代码:
出错时继续下一步 strDirectory = InputBox(Message, Title, "For example - P:\Windows\")
If strDirectory = "" Then
'Wscript.Echo cancelledText
Else
'Wscript.Echo enteredText & strDirectory
etc...
我找到了一些片段,结果发现使用 inputBox 非常简单。
HTH。
詹姆斯
I have a vbscript that runs on the command line in xp. It accepts one argument for the path to a directory. Is there a simple way to prompt the user in the command line box for this?
If not, I can just echo what was passed in to show the user what they actually typed in case of typos.
Thanks,
James
Aftermath:
Here is the code I ended up with:
On Error Resume Next
strDirectory = InputBox(Message, Title, "For example - P:\Windows\")
If strDirectory = "" Then
'Wscript.Echo cancelledText
Else
'Wscript.Echo enteredText & strDirectory
etc...
I found some snippets and it turned out to be really simple to work with the inputBox.
HTH.
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
WScript.StdIn< /code>
属性从标准输入读取。如果要在调用脚本时提供路径,可以将该路径作为参数传递。您可以在
WScript 中找到它.Arguments
属性。You can use the
WScript.StdIn
property to read from the the standard input. If you want to supply the path when invoking the script, you can pass the path as a parameter. You'll find it in theWScript.Arguments
property.您可以使用选择命令, choice
它将错误级别设置为所选值。我认为它是在 DOS、Windows 95,98 中附带的,然后 MS 放弃了它,然后在 Windows 7 中又回来了,可能还有 Vista
P.D.。哦,没关系,我再读一遍,你已经在 XP 中了。还有其他选项,例如
set /p name= What is your name?
将创建一个您可以使用的变量 %name%you can use the choice command, choice
it sets errorlevel to the value selected. I think it comes with DOS, Windows 95,98, then MS dropped it and then came back again in Windows 7 and probably Vista
P.D. oh never mind, I read again and you're in XP. There are other options, like
set /p name= What is your name?
would create a variable %name% you can use