Interacting with Users

Let’s try a script with a few more features, again using Notepad enter the following text, and save it as "script2.vbs":
Dim strName 'Define the variable

strName = InputBox("Enter your name:") 'Get the users name

WScript.echo "Hello " & strName 'Show the user the name entered

When you run this script, the first thing you will see is an input box requesting your name (this is generated with the InputBox() function), enter your name and click OK.

InputBox Example

The next screen will show you the name entered on the first screen using the WScript.Echo method.

Popup Example

To see how this script works let’s go through it line-by-line; on the first line we define the variable "strName", a variable is used to store information, in this case a persons name. On the second line we used to InputBox() function to request the user for some information, we then take the response and place it in the "strName" variable. On the final line, we display the information back to the user, for this we used the WScript.Echo method that prints the supplied text on the users screen.

< Hello World!

1 + 1 = ? >

PC Tools, the PC Tools logo and Spyware Doctor are either trademarks or registered trademarks of PC Tools Technology Pty Ltd. Microsoft, Windows, Windows Vista, the Windows logo and / or other Microsoft products referenced are either registered trademarks or trademarks of Microsoft Corporation in the United States and / or other countries.