Sunday, March 2, 2008

Using VBScript to display message boxes

In today's article, I'll show you how you can make really cool looking VBScript popup boxes to amaze and shock your friends and colleagues. Basically, with VBScript and a little time, you can create a Message box on any Microsoft Windows computer with a custom text of your choice.



This example was taken off the autoitscript website. You can create such message boxes with any text you want.

Here's how:

Step 1 - Open up a simple text editor, such as notepad.

Step 2 - Enter in the following line
msgbox"Have a nice day!",16,"Your title here"

You will replace the text in quotes "Have a nice day!" with a message of your choice (don't remove the quotes!)

The number after the message text is an indicator of what icon you may want to use.
Here are some examples :
  • Icon number 16 is a ERROR sign, a circle with a cross
  • Icon number 32 is a QUESTION mark sign "?"
  • Icon number 48 is a WARNING sign, a triangle with a "!" on it
  • Leaving it as a 0 will give no icon.
The last field is for the message title, which you can change to anything you want as well.

Step 3 - Save it as a VBS file. When saving, make sure you select "all files" and enter the extension ".VBS" (for example, your file may be named "hello.vbs")

Step 4- Double click to run. Simple as that.

The possibilities of what you can do with this are endless. Obviously you could pull some pranks on other people's computer by leaving messages such as "system failure" or anything you like. You can also use such messages to leave notes or alerts.

A little more fun: Adding this line

WScript.Sleep 5000

before the msgbox line will force the script to wait 5000 miliseconds before running and displaying the messagebox. In this way you can set a timer (or a fuse) to your script so it only shows after the specified time has passed.

I hope this tutorial has been useful to you. Have fun on your computer with VBScript!

No comments: