Skip to content
Related Articles

Related Articles

How to Make, Save, and Run a Simple VBScript Program?

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 05 Aug, 2021
Improve Article
Save Article

VBScript is a lightweight scripting version of the popular Microsoft Visual Basic, developed by as the name suggests, Microsoft. It is used to develop dynamic web pages. It is much lighter compared to Visual Basic programming language but works as a scripting language like JavaScript. To run VBScript on the client-side, the client must have to use Internet Explorer because other browsers are still not supported by the VBScript. 

How to make a VBScript program?

Just like many other simple scripting languages, VBScript can be written on a simple word editor, like notepad and other such softwares (e.g. notepad++, Wordpad, etc.). Refer the following steps to get a better idea of making a VBScript program: 

Step 1: Open up a word editor of your choice (Here, notepad is used). 

Step 2: For now, here is a simple VBScript program that will make a simple message dialog box to appear on the screen. The code for such a program in VBScript is: 

a = msgbox("Have a good day, fellow GFG reader!", 0, "Making a VBScript program")


Code Explanation: You can put anything as long as it follows the variable declaration rules in VBScript instead of “a” which is at the beginning of the above code. Effectively, We can break and understand the above code in the following manner: 

put_any_Variable_name = msgbox("Your main text here", 0, "Your title text here")

To change the property of the dialog box with respect to what you need, refer the following data: 

0Only “OK” button will be displayed. ????
1OK and Cancel buttons will be displayed. ???? ❌
2Abort, Retry, and Ignore buttons will be displayed. ???? ???? ????
3Yes, No, and Cancel buttons will be displayed. ✅❎❌
4Yes and No buttons will be displayed. ✅❎
5Retry and Cancel buttons will be displayed. ???? ❌
16Critical Message icon will be shown in the dialog box ????
32Warning Query icon will be shown in the dialog box ❓
48Warning Message icon will be shown in the dialog box ????
64Information Message icon will be shown in the dialog box ⏺
0First button will become default
256Second button will become default
512Third button will become default
768Fourth button will become default
0Triggers the application modal (basically, the current application will stop working until the user responds to the dialog box)
4096Triggers the System modal (basically, all applications will stop working until the user responds to the dialog box)

Change “0” in the above written code with any of the numbers provided just above. 
To get more than one above mentioned property in you dialog box, you can simple write, for example: “0+16”, instead of “0” in above code. 
For reference, the code: 

hydro = msgbox("Remember to drink water!", 0+64, "Hydration Check")

will give the following output: 

That’s it, we have just written a basic VBScript program that will display a dialog box as output. Now onto saving this program. 


How to save a VBScript program?

Follow the steps given below to save a VBScript program: 

Step 1: Press Ctrl + Shift + S on the keyboard, Or click File>Save As on the notepad window, this will open up a Save As dialog window asking where to save the current notepad document. 

Step 2: Now write any file name of your choice for this notepad document but make sure you write .vbs as its extension. Make sure to add “.vbs” after writing the file name in the “File name:” field. 

Step 3: Now, change the value of “Save as type:” field from “Text Documents (*.txt)” to “All Files (*.*)” by clicking on it with help of the drop down menu. 

Step 4: Finally, click on save after choosing an appropriate location of where the file should be saved to. 


How to run a VBScript program?

Now, this is a very simple thing to do, simply double click on the now saved .vbs file from wherever you saved it and voila! It will run and give you the following output: 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!