VBS is a short form for Visual Basic Script.
As implied in its name, it is a script and it is written in a scripting language.
VBScript is a subdivision of Microsoft’s Visual Basic for Application family.
It is usually included in the individual application within Microsoft Office, Microsoft Project, and a host of third-party applications like AutoCAD. VBS files carry a ‘.VBS’ or ‘.VB’ extension.
In this article, we will get to understand the basis of VBScript, its features, drawbacks, and how to run a simple program.
History of VBScript
VBScript was introduced by Microsoft in the year 1996 and its first version was 1.0.
It began as a client-side scripting language to create functional and interactive web pages.
The primary intention for its development was to assist developers to leverage their knowledge of Visual Basic in internet scripting.
However, it had a major liability; it was not supported by the Netscape Navigator (which happens to be one of the two most popular web browsers in the 90s)
On the other hand, the two major web browsers (ie. Microsoft Internet Explorer and Netscape Navigator) supported a common scripting language called ECMAScript, which became the de-facto standard.
Despite this setback, VBScript gained more ground and became the major scripting language in three other areas:
- Outlook forms
- Windows Script Host (WSH) scripts
- Active Server Pages (ASP) applications
A key merit of VBScript is its ease of learning especially for those without any programming experience.
This is simply because it utilizes the same familiar and easy syntax that has made Visual Basic Application (VBA) popular.
The current stable version of VBScript is version 5.8, and it is available as part of Windows 7 and Internet Explorer 8.
Uses of VBScript:
- VBScript is used as a scripting language in Quick Test professional (One of the popular Automation testing tools)
- VBScript is used for client-side scripting ( in Microsoft IE)
- It gives interaction to web pages.
- It is used by windows system administrators for automating windows desktop
- It can also be used for server-side scripting
NOTE: This requires the use of a Microsoft web server such as an Internet Information Server (IIS), or, a Personal Web Server (PWS), and a packaging such as Active Server Pages (ASP).
What Environment can VBScript be Executed?
VBScript can be executed successfully in the following environment:
- IE (Internet Explorer)– The Internet Explorer happens to be the simplest hosting environment to run a VBScript.
- IIS (Internet Information Server) – This is Microsoft’s web server
- WSH (Windows Script Host)– This is the native hosting environment of the Windows Operating system
Features of VBScript
The following are some of the key characteristics features of VBScript
- It is a lightweight scripting language and has a fast interpreter.
- VBScript is easy to learn and implement
- VBScript has a simple syntax and it is not case sensitive
- It utilizes Component Object Model (COM) to access the elements of the environment in which it is running
- It is an object-based scripting language and not an object-based programming language
- The execution of a VBScript code can only be successful in a Host Environments such as Windows Scripting Host (WSH) Internet Explorer (IE), and Internet Information Services (IIS)
Prerequisites for Creating and Running a Simple VBScript.
There are two basic tools needed to create and run a VBScript code. These are:
- Internet Explorer browser (I recommend that you use the Internet Explorer version 6 and above)
- Text Editors
Creating a VBScript code
Similar to other simple scripting languages, VBScript can be written on text editors and other software.
To create a VBScript, simply follow the steps outlined below:
Step 1: Open the text editor (Here, notepad is used).
Step 2: Copy and paste the code below
a = msgbox(“Learning on this Platform is FUN!”, 0, “Creating a VBScript Program”)
Step 3: Click the File menu then select Save As (or Press Ctrl + Shift + S). This will open a Save As dialog window.
Step 4: In the ‘File name’ field, Input the file name of your choice. Ensure you append ‘.vbs’ extension
Step 5: Select “All Files (*.*)” by clicking on the drop-down menu, in the “Save as type” field.
Step 6: Choose the preferred location where the file should be saved and Click on the ‘Save’ button.
Running a VBScript Program
To run a VBScript program, simply double the .vbs file, and voila! It displays.
Possible Challenges that may be encountered with VBS files
There are several reasons why you may not be able to run a VBS file.
However, outlined below are some of the possible problems:
- No suitable software that supports VBS among those installed on your device
- The VBS file you are trying to run may be corrupt
- The links to the VBS file in registry entries may be incorrect
- The description of the VBS from the Windows registry was accidentally deleted.
- Incomplete installation of an application that supports the VBS format
- The VBS file you are about to run may be infected with an undesirable malware.
- Not enough hardware resources to cope with the opening of the VBS file in your device
- Drivers of equipment used by the device to open a VBS file are out of date.
Peradventure the outlined reasons do not exist in your case, and you are not still able to open/run the VBS file, it is best advised to seek the assistance of a professional staff
Drawbacks of VBScript
- VBScript code can only be processed by the Internet Explorer browser. Other browsers (like Mozilla Firefox, Google Chrome, Opera, Safari, etc) do not process VBScript code.
- VBScript only runs on computers with the Microsoft Windows operating system. Hence Operating systems like the Mac, Linux cannot run VBScript codes
- Just like any other scripting language, VBScript has undergone several changes over the years.
- VBScript code is used as the default scripting language of ASP
- The command Line support in VBScript is limited
- Debugging activity is difficult because of the unavailability of a development environment.
Conclusion
The current version of VBScript is 5.8, and there is no hope for more new versions.
For the most part, VBScript is no more being used.
Most Processes that could be carried out using VBS files are now easily performed using Windows PowerShell.
In addition, Microsoft in 2019 announced its decision to discontinue the VBScript support on Internet Explorer (which is the only web browser that ever-supported VBScript).
Developers were further advised to update their websites using JavaScript.