"Tony Bansten" <tonytony@xxxxxx> wrote in message
news:49c9f0be$0$31862$9b4e6d93@xxxxxx-online.net...
>I would like to read a user input from command line and store it in a
>variable aaa.
>
> In good ol' DOS batch scripts there is a command:
>
> set /p aaa="Please enter value: "
>
> How do I do this in VBscript?
>
> Is there a way to define a default value? In other words if the user
> simply hits RETURN
> the value in variable aaa should not be empty but contain instead e.g.
> "unknown" or 0 (=zero)
>
> How do I define such a default value in VBscript?
>
> Again: the input should not be entered in a GUI based entry field but at
> the command prompt.
>
> Tony Strange . . . for a long time people have been complaining about the
unfriendly black-screen user input method offered by set /p, and now you
wish to use precisely this unfriendly technique . . . AFAIK, VB Script has
no such facility. Its input tool is, as you probably know, the InputBox
method.
A rather clumsy way to meet your requirement would be to use a batch file
that does two things:
- It uses set /p to prompt the user for an input.
- It writes the response to a text file.
Your VB Script will also do two things:
- If invokes the batch file like so:
oWshShell.Run "d:\temp\test.bat", 3, True
- It reads the input from the text file.
I think the InputBox method would be a lot more elegant.