The VBScript Network and Systems Administrator's Cafe

Oct 23 2008   1:43PM GMT

A simple way to gather keyboard input from with in a VBScript

Jerry Lees Jerry Lees Profile: Jerry Lees

While entering data at the command line for a script to use is sometimes helpful like we discussed in  How to use command line arguments in VBScript via the Wscript.Arguments Object. However, if you recall in a later blog entry, Using the windows file dialog box in VBScript to provide file selections and populate script options , I mentioned It’s sometimes just not practical! In that entry we discussed a slick way to use the standard windows functions to have a user select a file– but even that sometimes isn’t good enough. Sometimes you just need the user to enter other stuff into the program.

Well, you can easily do this with in VBScript as well, and it’s just one line of code! You use the InputBox command and it’s that easy. You simply assign the return to a variable of your choosing and specify first a Prompt (or directions) to a user and then you optionally can specify a title for the window that will be displayed. Below is an example that places the return of the InputBox command in a variable called Str, displays a prompt saying “Your Prompt here.” and has “Window Title here” in the title bar.

Str = Inputbox(“Your Prompt here.”, “Window Title here”)

There are other options as well, but they are typically not used in most cases. More information can be obtained from Microsoft in their InputBox Function documentation.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: