Picture of Fun with Easy VBS!!!
A Beginners guide to fun, and easy to do visual basic script. VSB may seem hard to some, but in fact it is really easy. Windows can even run it without a compiler! If you know javascript, it should be really easy for you.
Remove these adsRemove these ads by Signing Up

Step 1: Basic Message Boxes

Picture of Basic Message Boxes
Ok so lets go over the Basics.

Have you ever seen a message box like the one below,
you probaly have. These are used to alert users of whatever you want to say.

You can create your own by using the Function Msgbox

So the code to a message box that says hi would look like this,


Alternately you can make an unkillable message box by making a simple loop by using the Do, Loop commands.

Now that we covered message boxes, lets move to more advanced message boxes.

Step 2: Games and stuff

Picture of Games and stuff
If you ever wonder how to make text games than look no further. I might be wrong, but I believe that they used vbs. Now a lot of vb scripts use a compiler, but windows doesn't need one. Just type cscript before the file path, now if you know how to make bat files, then you can automate this process, but we wont get into that in this instructable.

Here is a little game i made

Option Explicit

Dim Answer

'types the question

Wscript.StdOut.Write "Nice Day Isin't it? "
answer = Wscript.StdIn.ReadLine

'if you type yes t

If answer="yes" Then
Wscript.echo ("I hope it stays this way")

'If you type no

ElseIf answer="no" Then

Wscript.echo ("I hope it gets better")

'anything else


Wscript.Echo ("GoodDay to you")


End If

now basically save this as .vbs and use the method before to run it.

Step 3: The Auto Typer

Picture of The Auto Typer
This code it to type something over and over again. I don't know how it is useful, but if you run it, you'll have to kill it in the task list

set shellobj = CreateObject("WScript.Shell") "cmd"


shellobj.sendkeys "Y"
wscript.sleep 200
Shellobj.sendkeys "o "
wscript.sleep 200


1-40 of 47Next »
HiddenHer05 months ago


Im trying to make a msgbox script where when you open it it says something like usual, then we you close it it waits a few seconds and opens again. Is this possible? if so can I have some help?

BMP1 HiddenHer01 month ago

do you want the loop to be infinite??? if so, use this:
Set objShell = WScript.CreateObject( "WScript.Shell" )
msg = "what you want the box to say"
wait = 1000 'this is how long it waits before the next text box, 1000 = 1 second

wscript.sleep wait

if you don't want it to be infinite:
Set objShell = WScript.CreateObject( "WScript.Shell" )
msg = "what you want the box to say"
wait = 1000 'this is how long it waits before the next text box, 1000 = 1 second
loops = 10 'how many times you want the loop to go

count = 0
Do while count < loops
wscript.sleep wait
count = count + 1

Riaan1113 years ago

I just want to know how to make a message box do something depending on what option you select (yes,no,cancel)

Say for example I make a message box and a person gives an input, depending on which input it will open another message box eg. "Are you happy" when the person selects the "Yes" option it goes to another message box saying "That's good" and when they say no, something else comes up.

Any help on this would be much appreciated
Thanks in advance
0 - ok button only 1 - ok and cancel 2 - abort, retry and ignore 3 - yes no and cancel 4 - yes and no 5 - retry and cancel
these set button values in a msgbox between quotes. the 3 sets it to yes, no, and cancel.
dim var1  
var1=msgbox ("am i cool?,3,"mthom41")
this creates a variable called var1, then sets its value to a msgbox output.
1 = OK 2 = Cancel 3 = Abort 4 = Retry 5 = Ignore 6 = Yes 7 = No
these are button return values.
now... you need to combine these with an if.. then.. statement and polish it up a little

dim decision
decision=msgbox ("'Sigghhhh...' I should try going somewhere." &vbnewline& "I'll take a step... or i could not, and sit down",3,"Yes=step No=sit and think. Finally, Dialogue!")
if decision=6 then
msgbox "'AAAAHH!!!!' I tripped over a cable!!!",48,"Falling....."
wscript.sleep 4000
msgbox ".............",48, "you are knocked out :("
else if decision=7 then
msgbox"I'll just sit here and wait...zzzzzzz",64,"Hope i don't fall asleep..zzzzzzz"
wscript.sleep 4000
else if decision=2 then
msgbox"You can't avoid it"
end if
end if
end if

this makes a series of boxes... well just look at the pics...

mthom41 mthom412 years ago
sorry. pic 1 is the main box, 2 is cancel, 3 is no, and 4 is yes
Set wshShell =wscript.CreateObject("WScript.Shell")
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wshshell.sendkeys "{NUMLOCK}"
wshshell.sendkeys "{SCROLLLOCK}"
DJP4VEP5 years ago
you arnt actually teaching anyone how to create a script. what is the point in this instructable? im wanting to know what to put at the end of a fake virus script i have made in order to shutdown the computer after 60 secs. please help me
animan1 DJP4VEP5 years ago
to get a shutdown timed to 60 seconds you mean? are you using batch or vbs?
Batch: shutdown -s -t 60 -f
dim objshell
set objshell = createobject( "shutdown -s -t 60 -f"

This is not completely reliable i may be wrong but it is along those lines.

*for more batch shutdown options open cmd and type "shutdown /?"
UBERBANKAI4 years ago
Hey, is there a way to have your computer run like a sound file when you hit yes on a message box?
Say i were to have a message box say: (in text) Hello I am a virus, don't be alarmed.
then it would have just an ok button  then when they press ok it  plays some sound from their computer.
yes put the sound file in the same folder as the script. Enter this in the script...

set wshshell = wscript.CreateObject("")

a=msgbox ("Hello I am a virus, don't be alarmed.", 16) "file.wav"

I assumed the file was a wav file. Where it says file.wav type the full filename like
music.mid or tada.wav
17hmr2434 years ago
just funny way to shut pc down

so write u own funny mesg inbetween " "
so it could be

onclick=msgbox ("your hard drive has failed please format",2,"ph home to late shutting down")

now u can change to numbers from 1 to 20 to get dif boxes
copy past into notpad save as any thing u whant but must end in .vbs

all so chang the .vbs icons to avi icon and snoopy people will click on it and it will just turn off u pc
google that part im tyed off to bed have fun

onclick=msgbox ("your hard drive has failed please format",2,"com%dot disk format fat32")
onclick=msgbox ("your hard drive is running to fast",13,"com%dot disk format fat32 restart")
onclick=msgbox ("failed please format",14,"com%dot disk format fat32 restart")
onclick=msgbox ("save and exit now",15,"com%dot disk format fat32 restart")
onclick=msgbox ("sending passwords",16,"com%dot disk format fat32 shut down")
onclick=msgbox ("sending bannking details",17,"com%dot disk format fat32 restart")
onclick=msgbox ("sending b.s.b details",18,"com%dot disk format fat32 formating hard drive")
onclick=msgbox ("thank you for your time and $",19,"you have just been hacked")
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "%windir%\system32\shutdown.exe -s"
crjeea 17hmr2433 years ago
try using the command at the end instead...

shutdown /s /f /t 00
nova4 years ago
Hey mdkelsh, have u considered batch programming? it is mutch simpler and easier to use.
mdkelsh (author)  nova4 years ago
 Yes, I program in python now, since I consider VBS to be defunct
nova mdkelsh4 years ago
 ok, cool, i will check out some of your files! :D
RedFlash5 years ago
Your code is loopy, when I executed it, my computer started going crazy. Scroll bars going loopy, when I tried to delete the file, it kept on opening it. I had to reboot my computer to stop it. Not good :(
Mirror Mage5 years ago
both this one and the one by smith2martin just doesn't work
BAD VBS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Does not work
geeklord6 years ago
Alright then. How do you get this "unkillable" box to go away without shutting down ur computer? Task manager isn't finding it either.....
A VBScript file is not an executable. The files are handled by the windows scripting host.. Kill wscript.exe
doesn't even pull that up
Make sure you are in the processes tab. What version of windows do you have? That's what it's called in XP (at least SP2)
Or, see if you can find cscript.exe in Task Manager. It is possible that it handles vbscript on your computer.
thx, got it now
Go to task manager, "Processes" tab, then find wscript.exe and kill it. This goes for all VBS running scripts.
will4215 years ago
How do you open notepad and make it maximized?
El Mano5 years ago
An interesting -ible for a programmer who knows the basic structure and operation of VBS. As for me, all I can do is get my computer to display a basic Message Box that I isolated from a VBS password-protection program. Perhaps you could write an instructable that will explain how VBS works: how to set and use variables, program organization, and the like. Then you could put a list of commands like "Msgbox("hi")" at the end, so instructees could learn how to construct a basic program and then have a quick reference of functions. Show people how to use a command and why it works, instead of simply saying "This creates a message box! Have fun!"
I don't get it explane it more simply
nativman6 years ago
hello i will be posting later a vbs that will act as run.reply me if you want.
dim x
dim oShell
Set oShell=WScript.CreateObject("WScript.Shell")
x = Inputbox("Run")
oShell.Run x

Note: this only work for the ff. script host
1.WScript Scripting host
2.CScript Scripting host
unless you own a vbs editor.
geeklord6 years ago
How about hte little bubbles that pop out of the right side of the toolbar?
twenglish16 years ago
this is awesome but i have one thing to say at the begining you typed vsb and im pretty sure you meant vbs(its in the intro)
im not listening to you any more. as soon as i tried to save the matrix, my pc started typing random things in the command line thing
awkrin6 years ago
and this thing IS dangerous. if u end the program too early, it will "type" space and backspace in whatever window u are.
it sayas for the matrixs thing no script verifyed!
for me it ran too fast
(removed by author or community request)
mdkelsh (author)  YummyPancakes6 years ago
I changed it
1-40 of 47Next »