How to Make, Save, and Run a Simple VBScript Program?
Last Updated :
05 Aug, 2021
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:
Code | Property |
---|
0 | Only "OK" button will be displayed. ???? |
---|
1 | OK and Cancel buttons will be displayed. ???? ❌ |
---|
2 | Abort, Retry, and Ignore buttons will be displayed. ???? ???? ???? |
---|
3 | Yes, No, and Cancel buttons will be displayed. ✅❎❌ |
---|
4 | Yes and No buttons will be displayed. ✅❎ |
---|
5 | Retry and Cancel buttons will be displayed. ???? ❌ |
---|
16 | Critical Message icon will be shown in the dialog box ???? |
---|
32 | Warning Query icon will be shown in the dialog box ❓ |
---|
48 | Warning Message icon will be shown in the dialog box ???? |
---|
64 | Information Message icon will be shown in the dialog box ⏺ |
---|
0 | First button will become default |
---|
256 | Second button will become default |
---|
512 | Third button will become default |
---|
768 | Fourth button will become default |
---|
0 | Triggers the application modal (basically, the current application will stop working until the user responds to the dialog box) |
---|
4096 | Triggers 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:
Similar Reads
Difference between JavaScript and VBScript JavaScript and VBScript are both scripting languages used to automate tasks and enhance web pages. JavaScript is widely supported across all modern browsers and platforms, making it the preferred choice for web development. In contrast, VBScript is primarily used in Internet Explorer and Windows env
2 min read
How to compile a Typescript file ? TypeScript is a robust, open-source programming language developed and maintained by Microsoft. As a syntactic superset of JavaScript, TypeScript enhances its foundational language by introducing additional features, including strong typing and object-oriented programming capabilities. Unlike JavaSc
3 min read
How to Install Google Apps Script into Google Docs Imagine having the ability to customize Google Docs and automate tasks to simplify your daily processes. Google Apps Script provides an effective way to enhance the functionality of Google Workspace apps, allowing users to integrate custom solutions. Whether you're a beginner or an experienced user,
8 min read
How to Run PowerShell Script From CMD Executing PowerShell scripts from the Command Prompt (CMD) is a common task for developers and system administrators, essential for automation and integration. In this blog post, weâll guide you through the steps to run a PowerShell script using CMD, covering key commands and their functions to help
4 min read
How To Execute HTML Program? HTML (HyperText Markup Language) is the standard language used to create web pages. Executing an HTML program is the process of rendering the code in the browser to display a web page. There are several approaches to running HTML code each suitable for the different environments and use cases. we wi
2 min read
How to Create an Application Boom Virus? The virus that we are building here will automatically open up random applications of the PC until the PC freezes. This can be a pretty annoying virus. For the Creation of the Virus follow these steps: Step 1: Press the Window + R Button from the Keyboard. This will open the Run Dialog book will Ope
2 min read
How to Run JavaScript in Visual Studio? To run JavaScript in Visual Studio, you can either use Node.js in the Terminal or the Code Runner extension. Both methods allow you to execute JavaScript code easily and efficiently within the Visual Studio environment.Using Node.js in TerminalNode.js is a JavaScript runtime that allows you to execu
2 min read
VBScript | Introduction The VBScript stands for Visual Basics Script language. Basically it is the combination of Visual Basic programming language and JavaScript language. VBScript was invented and maintained by Microsoft. It is used to develop dynamic web pages. It is much lighter compared to Visual Basic programming lan
2 min read
How to Create a File in CMD Creating a file using Windows GUI is very easy, but did you know that you can also create files using Windows CMD? Now, this article will walk you through the steps to create a file using CMD, ensuring that you can efficiently manage your files directly from the command prompt.How to Create a File i
4 min read
How to Create a Virus to Open Up Multiple Window Automatically? The virus that we are going to create in this article will automatically open up multiple windows in the victim's Windows PC.This is an annoying type of Virus because as per the heading, this is capable of opening multiple window screens in front of the user without allowing the user to open any oth
2 min read