VBScript Tutorial

VBScript is a programming language, that is built in in most Windows PCs.
To get started, open Notepad, or any other notepad, and type in MsgBox("Hello, World!"). Run it, and you will see "Hello, World!" and a OK button.

Step 1: InputBox

Now, let's make a simple Inputbox. It's similar to "MsgBox", but with "InputBox".
InputBox("What is your name?") Run that, you will see "What is your name?" and a Inputbox.
Now, you have only seen some of the powerful features that VBS has.

Step 2: Speak!

Many people think that they can make a computer talk. That is true, with VBS.
Turn your speakers on, and type this into Notepad.
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Hello."
-------------------------------------------------------------------------
That was MS Anna speaking. Try this:
-------------------------------------------------------------------------
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Look!"
do
wscript.sleep 200
wshshell.sendkeys "{NUMLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 200
wshshell.sendkeys "{sCROLLLOCK}"
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wscript.sleep 100
wshshell.sendkeys "{NUMLOCK}"
loop
-----------------------------------------------------------------
You computer will say "Look!" and then flash the LOCK buttons.
Press Ctrl+C to stop it.

Step 3: Calling "370 VBS"

Calling VBS from a Batch file.
Let's see: You have a Batch file and you want to have VBS in it. You can't have VBS 'in' it, but you can call the VBS script.

VBS Script:
--------------------------------------------------------
MsgBox("Hello!")
--------------------------------------------------------
Batch File:
--------------------------------------------------------
start "C:\Users\You\Desktop\something.vbs"
--------------------------------------------------------
Start the batch, and, it will start "something.vbs" instead.

Share

    Recommendations

    • First Time Author

      First Time Author
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • PCB Contest

      PCB Contest

    3 Discussions

    0
    None
    Prof. Pickle

    6 years ago on Introduction

    This isn't finished, isn't it? The things you teach in here have already been covered a million times over. What I wanted to know is new commands, things it can do. Not just message boxes and the computer talking to you. Nice try though.