3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Comprehensive VBS And Batchfile Tutorial - Beginner To Advanced

Comprehensive VBS And Batchfile Tutorial - Beginner To Advanced
This is my first instructable, so take it easy, and feel free to recommend any changes in future instructables.

In this instructable I will show you how to write various visual basic scripts (vbs) and batchfiles (bat), as well as how to interconnect the two, so to speak.  All of the example viruses are safe to run on your computer, however some of them (will be clearly stated) may crash your computer just by opening up too many windows at once.

I will provide both the source code and instructions on how to create/run/disable all of these viruses.  It is highly recommended that you read an entire step before trying to execute one of these, as some of them can be hard to stop.  At the same time, I assure you none of them will ruin your computer.  Of course, I take no responsibility for any of your actions, and if you write the code wrong and it does ruin your machine, that is not my fault, and I cannot be held accountable.  For any of the code throughout the entire instructable, just copy and paste.  It will save you a lot of time.

Please note that I am doing all of these on Windows XP, and some the commands may not be the same on other operating systems.  Anyway, enough of this gibberish, let's get to scripting!
 
Remove these adsRemove these ads by Signing Up
 

Step 1Basic VBS Messages

Basic VBS Messages
First off, I will show you many examples of different styles of error messages that can be useful for conveying different ideas or pranking different people.

Open notepad (if you don't know where that is, just go start->run and type "notepad.exe" without the quotes and hit enter).  Here are the different error codes and what they do.  By the way, just edit the original and change the number, as retyping all of these would take a LONG time.

text=msgbox ("Message",0,"Title")     -This is a basic message with a beep and an ok button.
text=msgbox ("Message",1,"Title")     -This adds a cancel button to the first one.
text=msgbox ("Message",2,"Title")     -This has buttons "abort", "retry", and "ignore", and the beep.
text=msgbox ("Message",3,"Title")     -Has buttons "yes", "no", and "cancel".
text=msgbox ("Message",4,"Title")     -Just the yes/no
text=msgbox ("Message",5,"Title")     -Retry/cancel
6 through 15 are exactly the same as 0
text=msgbox ("Message",16,"Title")     -This is the angry beep error message version of 0.
text=msgbox ("Message",17,"Title")     -16 with cancel button
text=msgbox ("Message",18,"Title")     -16 with abort/retry/ignore
Starting to detect a trend here?  It continues on like that.
text=msgbox ("Message",48,"Title")     -Different beep, and a yellow caution sign, with ok button.
Continues normal pattern from there.
At 64 we get a different beep and a question mark icon.

I know this is very boring, so I'll cut short here.
To run this, first save it as whatever.vbs  - make sure to select all file types, and not text files.
Then, just double click the vbs icon where you saved it.

Of course, you can change the message and the title to whatever you want.

Lastly, you can create loops in vbs like so:

do
msgbox "Hi"
loop

This is an infinite loop, but you can stop it with task manager.  Just go to processes and end the wscript.exe process.

« Previous StepDownload PDFView All StepsNext Step »
16 comments
Nov 30, 2011. 4:12 AMtheATVmadman says:
im not sure where i've gone wrong with my script,... but it's not opening my file. If you could just look over my script and tell me my fault that'd be great.
set wshshell = wscript.CreateObject("wscript.shell")
wshshell.run "Notepad"
wscript.sleep 2000
wshshell.AppActivate "Notepad"
wshshell.sendkeys"Y"
wscript.sleep 145
wshshell.sendkeys"o"
wscript.sleep 145
wshshell.sendkeys"u"
wscript.sleep 145
wshshell.sendkeys" "
wscript.sleep 300
wshshell.sendkeys"A"
wscript.sleep 145
wshshell.sendkeys"r"
wscript.sleep 145
wshshell.sendkeys"e"
wscript.sleep 300
wshshell.sendkeys" "
wscript.sleep 145
wshshell.sendkeys"B"
wscript.sleep 145
wshshell.sendkeys"e"
wscript.sleep 145
wshshell.sendkeys"i"
wscript.sleep 145
wshshell.sendkeys"n"
wscript.sleep 145
wshshell.sendkeys"g"
wscript.sleep 300
wshshell.sendkeys" "
wscript.sleep 145
wshshell.sendkeys"H"
wscript.sleep 145
wshshell.sendkeys"a"
wscript.sleep 145
wshshell.sendkeys"c"
wscript.sleep 145
wshshell.sendkeys"k"
wscript.sleep 145
wshshell.sendkeys"e"
wscript.sleep 145
wshshell.sendkeys"d,"
wscript.sleep 300
wshshell.sendkeys" "
wscript.sleep 145
wshshell.sendkeys"B"
wscript.sleep 145
wshshell.sendkeys"e"
wscript.sleep 300
wshshell.sendkeys" "
wscript.sleep 145
wshshell.sendkeys"A"
wscript.sleep 145
wshshell.sendkeys"f"
wscript.sleep 145
wshshell.sendkeys"r"
wscript.sleep 145
wshshell.sendkeys"a"
wscript.sleep 145
wshshell.sendkeys"i"
wscript.sleep 145
wshshell.sendkeys"d"
wscript.sleep 1000
wshshell.run"Fake trojan.bat"
Aug 31, 2010. 12:05 PMdllhacker says:
i tried to type in the wshshell.run "batchfile.bat" command in a vbscript but it wouldn't run my file? (i made a shutdown batch file named shutdown.bat so i replaced batchfile.bat with shutdown.bat) plz help! im using a windows xp computer so it should work but instead i get a popup message saying i typed in an incorrect script command. is there anything i missed out on?
Mar 7, 2011. 2:13 PMmatthart77 says:
Just name it something other than Shutdown.bat
In the order of how windows looks for file extensions, com and exe files come before .bat, so it is running the internal shutdown command and not your shutdown.bat file
Sep 7, 2010. 12:40 PMdllhacker says:
yeah both the files are in the desktop folder. i did some more internet surfing and found another script that works but i want it to be short and simple like yours so i could remember it more easily. here's the script i found

dim shell
set shell=createobject("wscript.shell")
shell.run "batchfile.bat"
set shell=nothing

i use windows xp sp3 if that may have a problem with the coding.
Sep 7, 2010. 12:44 PMdllhacker says:
is the wshshell.run "batchfile.bat" command just a small part of a bigger command and i didn't read the directions carefully or is the command just that small?
Sep 8, 2010. 4:23 PMdllhacker says:
Thank you soo much it worked now. i thought that the
set wshshell = wscript.createobject("wscript.shell") command was just for the send keys code. thanks greatly for your help i greatly appreciate it :D
Sep 13, 2010. 11:38 AMdllhacker says:
LOL ur awesome man u trueley are :D
Dec 6, 2010. 6:28 PMoutbreakgirl says:
Lame I know but how do I give this to someone ?
Aug 28, 2010. 9:24 AMnoobererer says:
For some reason when I ran this, all went well until it said "do" is not a reconized command and it did the same for "loop". I am using Windows 7, any ideas? Oh and thanks for this instuctable by the way! Very informative.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
1
Followers
1
Author:geekvig
All your base are belong to us.