Introduction: Learn VBS Programming for Pranks, Cool Stuff, Ect.

About: I love creating value, and discovering new things! I take things apart to see how they work, spend too much time learning about irrelevant things, and love making cool stuff, like Robots, electronic projects i…

This instructable is to teach you thew basics of Batch and VBS programming, whether you want to make a talking clock, a simple calculator program, or just need a few ideas for April fools. ;)

VBS is a programming language built into windows. Have you ever wondered how to make a window pop up and say anything you want it to? Have you ever wanted to scare your friends or parents with a really convincing fake virus? Make someone think their computer is sentient? What about make your computer talk to you?

If so, you've come to the right place! :D

A ton of credit goes to Super_Nerd and his Awesome instructable, thanks for such a detailed and comprehensive guide, and for a lot of the information in this instructable.

Note: These will only work on windows machines. Sorry, mac users. :/

Step 1: The Begining Basics: Your First Message Box

Surprisingly, there is very little to do for our first message box.

First, open notepad,

Next, type this in (Or copy/Paste)

x=msgbox("Message", 0 ,"Message along the top")

You can replace the Message and Message along the top with whatever you like. Keep the parenthesis though.

Click File, then Save as

Make sure you select "All files (*.*)" instead of "Text Documents (*.txt)" before saving, otherwise it will save it as a plain text document.

Type the name you want to save it as, followed by a .vbs

Save the file, then run it. If you did everything correctly, you should see a message box pop up on the screen! Now you can move on to customizing icons and buttons!

Step 2: The Begining Not So Basics: Adding Buttons and Icons!

Ok, so you've made your first message box pop up. Great! Now how do you add more buttons, options, and icons?

Did you notice the zero in the line here?

x=msgbox("Message", 0 ,"Message along the top")

The numbers there define what buttons and icons appear.

For the buttons:

0 - ok button

1 - ok and cancel

2 - abort, retry and ignore

3 - yes no and cancel

4 - yes and no

5 - retry and cancel

For the icons:

16 - critical message icon

32 - warning icon

48 - warning message

64 - info message

To use these, simply add the numbers to the code like this:

If I wanted a warning icon and yes and no buttons, I would write this:

x=msgbox("Is this a warning?", 4+32 ,"Warning!")

The number for the buttons goes first, then a plus sign, and then the icon number.

Now you should know how to add different buttons and icons to your message box!

Step 3: Have Fun With Message Boxes!

Ok! Now that you now the basics, you can prank your friends, awe them with your supreme skills of computer hacking, or just play around with it for fun!

A tip:

This is the code for the message boxes shown in the pictures for this step:

x=msgbox("When your computer talks back to you, then you know you're going crazy.", 48+2 ,"Perhaps this is just your imagination.")
y=msgbox("Actually, I think you really do need to see a doctor. Or maybe I should call an asylum?", 16+0 ,"A doctor would be recomended.")

Notice I put both commands in one file. You can do this, and they will play one after the other.

Step 4: Make Your Computer Talk to You!

So you want your computer to talk to you? It's very easy! Another simple VBS script, and it will be talking away!

Open notepad.

Copy in this code:

'
set speech = Wscript.CreateObject("SAPI.spVoice")

speech.speak "Hello Master, I am ready to do your bidding."

You can replace the "Hello Master, I am ready to do your bidding." part with whatever you like. Same as with the message boxes, keep the parenthesis.

Click File, then Save as
Make sure you select "All files (*.*)" instead of "Text Documents (*.txt)" before saving, otherwise it will save it as a plain text document. Type the name you want to save it as, followed by a .vbs, then save it.

Run it and 'see' (Hear) the results!

Step 5: Text Input Window:

Here's how to make a window that accepts a text input from you.

Type this into Notepad:

var=inputbox ("Text in window","text at top of window","default text")

The variable var is where the input is stored.

This doesn't do much by itself, but you can add it to other things to make something cool!

Step 6: Inspiration, Ideas, and Tips

If this has been enough for you, then good! I hope it helped! If not, I hope to add more later, but for now, take a look at Super_Nerd's very detailed instructable on the subject: https://www.instructables.com/id/The-Ultimate-VBS-T...

To make a VBS (Or Batch) file run when the computer
has been started up and logged onto, find the Startup folder under All Programs, and put your file(s) into it. When your unsuspecting victim logs on, they will be greeted by it!

Other cool things:

Text to speech program:

x=inputbox ("Enter text to convert into speech:","Text to speech convertor","Enter text")
' set speech = Wscript.CreateObject("SAPI.spVoice") speech.speak x

Password Program:

x=inputbox ("Please Enter Password","Please enter Password","")
if x = "Pizza is the Password" then x=msgbox("Correct! Welcome, Master!", 0 ,"Welcome, Master!") else x=msgbox("Incorrect.", 0+16+0+4096 ,"Password Fail") end if

I hope this instructable helps some people, comments and constructive criticism are always welcome! ;D

Coded Creations

Participated in the
Coded Creations