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.