Welcome to my first tutorial on how to make VBScripts with notepad. With .vbs files, you can create some funny pranks or deadly viruses. In this tutorial, I'm gonna show you basic commands like starting your script, opening files and much more. At the end, I'm gonna show you a summary of what you learned and I'm gonna give you some ideas and an example script, and some more scripts in beetween. Let's get to it!
Step 1: Starting Your VBScript
To start, you need to of course open notepad. You can right click on the desktop, on the menu that pops up go to new and then text document. You can also press the Windows button + R and type in notepad.
The first command is used to create script pretty much. Here's the command:
Set WshShell = WScript.CreateObject("WScript.Shell")
This I guess creates the script. Remember to paste it at the start of your VBS.
Oh, and remember to end name of every file you will create with commands shown with .vbs.
Step 2: Delaying Your VBS
In this step, I'll show you basic commands to help your VBS work properly. Sometimes without any delays your script will break.
The first command is WScript.sleep. You will most likely use it all the time, it delays your script. Here's how it works:
The first part of the command is of course, the command (wow). Then, you have the time that will be delayed. Every 1000 is the equivilant of one second.
In the example below there a message box will appear every 3 seconds after you hit OK on the previous one.
Step 3: Message and Input Boxes.
Now I'll TRY TO TEACH YOU how to use message and input boxes and a somewhat ADVANCED example that you can use yourself.
First the most basic, the simple and innocent message box. Here's an example command:
x=msgbox ("Your message" ,buttons+msgbox type, "Title")
After you start your amazing command, you have the message, then buttons, type of the message box and it's title.
There are 5 diffrent button types and 4 message box types. Here are all of them:
0 - OK button only 16 - Critical message icon
1 - OK and Cancel 32 - Warning query icon
2 - Abort, Retry and Ignore 48 - Warning message icon
3 - Yes, No and Cancel 64 - Information message icon
4 - Yes and No
5 - Retry and Cancel
So with that, our example command would be:
x=msgbox ("Message" ,0+16, "Title")
Now input boxes. These beasts have some more user interaction (wow), but you won't use them as often (or maybe...). Here's an example:
y = InputBox("Message here","Title here","textbox message")
Start the command, type in the message, title and textbox message. Simple stuff.
Let's go a little more advanced. Now you're gonna see a input box followed by a message box which has the whatever you typed in the input box.
Name = InputBox("Write your name below","Title","Type your name here")
x = MsgBox("Hi " & Name & " !",16,"hello")
The message box below is a little more complicated. First, you have your message, then something you typed in before and then continuation of the message. But nothing out of the ordinary. I think.
In the file below you can see all the diffrent message boxes and an input box.
Step 4: Opening .exe Files
With VBScripts you can also open .exe files. Here's an example command that opens calculator:
At the start you have the command, at the end you have the program you want to open. Not to much to explain.
The file below will open calculator, paint and CMD.
Step 5: Summary
In this tutorial you learned how to start your .vbs script, delay it, use message and input boxes, opening .exe files and ending your script. Now, let's go crazy with this. I'm gonna create a harmless but scary prank to troll your friends.
This example prank asks for your name, tells you it was not a good idea and opens like CMD like 30 times.
I hope you enjoyed reading this. Was this the dumbest thing ever? Did you actually learn something new? Fell free to tell me in the comments.