Definition

VBScript

What is VBScript?

VBScript is an interpreted script language from Microsoft that is a subset of its Visual Basic programming language designed for interpretation by Microsoft's Internet Explorer (IE) web browser. VBScript compares to other early scripting languages that were used for the web development, including the following:

  • Netscape's JavaScript
  • Sun Microsystem's Tcl
  • Unix-derived Perl
  • IBM's REXX

The only browser that supported VBScript was Microsoft's IE, which retired as of June 2022. Microsoft had disabled VBScript in IE in August 2019. JavaScript is now the dominant scripting language, in part because multiple browsers support it. With the end of IE, VBScript is no longer used for modern web development.

VBScript functionality is available in Microsoft's Edge browser for users who need to run a legacy web application that contains VBScript code. This is done using IE mode and changing the version of IE to IE10 in the operating system's group policy function.

Scripting languages are easier and faster to code compared to more structured compiled languages such as C and C++. They are ideal for smaller programs of limited capability or that can reuse and tie together existing compiled programs.

VBScript was Microsoft's answer to JavaScript. Both were designed to work with the interpreter that comes with a web browser. VBScript was designed for use with Microsoft's IE browser together with other programming that runs at the client including ActiveX controls, automation servers and Java applets.

How is VBScript used?

VBScript was mainly used to give functionality to webpages. It was originally used for client-side scripting in IE. Web developers could write and embed executable VBScript functions in the Hypertext Markup Language (HTML) of a webpage, which controls the presentation of data. VBScript was able to do things that HTML alone couldn't, such as generate data.

VBScript uses a component object model to access system objects and variables. It has been generally used in a Microsoft environment. Since Microsoft disabled it, VBScript has limited use. It is still used in some situations, such as the following:

  • It may be embedded in a legacy web application or site and there is no way to remove it.
  • It can be used for data prep and certain process automation functions in software tools like Microsoft Excel and Microsoft Power Automate tool.

Disadvantages of VBScript

The primary disadvantage of VBScript is that it has limited functionality. It only runs in IE, which Microsoft has phased out, and not in other browsers, such as Chrome or Firefox.

VBScript also runs in Microsoft's Internet Information Services -- Microsoft's web server -- and the Windows Script Host environment.

Other disadvantages of VBScript are the following:

  • It only works on Windows. A website containing VBScript can't be loaded on a Linux or Mac system.
  • It has limited command line.
  • There is no development environment.
  • VBScript has been the target of cybersecurity attacks. One example is the ILOVEYOU virus, which was a hidden VBScript program that users would mistake for a harmless text file. Once the file is opened, it deletes all files on the user's machine.

VBScript examples

Until IE's retirement, users could write a simple piece of VBScript code using IE -- preferably IE6 or later -- and any text editor. VBScript code was embedded in HTML code to modify dynamic websites.

Below is a simple example of VBScript embedded in HTML.

<html>
   <head>
      <title>VBScript Tutorial!!!</title>
   </head>
   <body>
      <script type="text/vbscript">
         document.write("VB script tutorial!")
      </script>
   </body>
</html>

The above code writes the text "VB script tutorial!" to a webpage. The phrase document.write tells the computer to write the string between the quotes on the page.

The user can save this code as an HTML file to their machine, and it will open in IE. To do this, the user can set their default browser to IE and double click the saved file. The text "VB script tutorial!" should display in the body of the webpage after the file opens.

Below is an example of the syntax used in VBScript to write a conditional statement.

Dim a, b, c
 a = 1
 b = 5 
 c = (a<=10)
If c = True Then
response.write("Looks right to me")
Else
response.write("Nope")
End If

If the value of a is less than or equal to 10, the program will print the phrase "Looks right to me." If the variable is greater than 10, it will respond "Nope." The phrase End If is used to finish the conditional statement.

VBScript vs. JavaScript: Which is better?

JavaScript is a more versatile language than VBScript because VBScript only worked in IE. JavaScript works in and is supported by most web browsers.

Other differences between the two scripting languages include the following:

  • JavaScript is a case-sensitive scripting language. VBScript is not case sensitive.
  • JavaScript only requires one statement to create a variable, whereas VBScript language requires several.
  • JavaScript was developed by Netscape; VBScript was developed by Microsoft.
  • JavaScript uses the .js file extension; VBScript uses the .vbs file extension.

The basics of both languages are relatively easy to learn. The Pluralsight Technology Index ranks JavaScript as a good language to learn for software development, above Python and HTML.

JavaScript and VBScript are fundamental software development technologies that most developers have a basic understanding of. Another common concept in development is the continuous delivery pipeline, which deals with the process for releasing software. Learn about the pros and cons of a continuous integration and delivery pipeline.

This was last updated in June 2022

Continue Reading About VBScript

Dig Deeper on Windows OS and management