Visual Basic Script

from Wikipedia, the free encyclopedia

Visual Basic Script (short: VBScript or VBS ) is a scripting language developed by Microsoft . It is closely related to Visual Basic (VB) and Visual Basic for Applications (VBA) and is commonly interpreted .

Areas of application

VBS can access all COM components with IDispatch interface that are available under Windows , in particular the libraries of Microsoft Office programs, databases such as Access and SQL Server , other applications and of course the libraries of the operating system. The use of normal program libraries (DLL files) is not intended and only possible with the appropriate COM support. In practice, there are three areas of application for VBS:

Windows operating system

The control of the Windows operating system for the automation of standard tasks is possible with your own scripts via the Windows Script Host (WSH). Windows mainly accepts VBS within .VBSand .WSFfiles executed by the Windows Scripting Host (since versions 2000 / ME) and within .HTAand files executed by Internet Explorer . and files are pure text files that can only communicate via a few dialogs. and files are HTML files that can be viewed accordingly. VBScript and JavaScript ( JScript ) can be mixed as desired within -, - and - files . The files are HTML files that can be expanded into an interactive form using VBS, JavaScript and the elements of HTML. When files are help files with the free Help Compiler files HTML from conventional compiled are. .CHM.VBS.WSF.HTA.CHM.WSF.HTA.CHM.HTA.CHM

Browser (client-side VBS)

VBS can be embedded in web pages to control the web browser on the client side (i.e. the browser is running VBS). VBS thus fulfills a function similar to Netscape's JavaScript , so it can be used for dynamic content and can integrate entire programs into a website .

On the client side, however, VBScript has not achieved great importance, as it is only directly supported by Microsoft's Internet Explorer (with plug-ins also by Mozilla), while JavaScript is supported by all browsers. In Internet Explorer, JavaScript and VBScript use similar security models and - in theory - can only access objects of the operating system to a limited extent. Because of its low usage, VBScript is not supported in Microsoft Edge . Since 2019, Microsoft has been using updates to disable the executability of VBScript code in Internet Explorer 11.

Web server (server-side VBS)

For servers under Windows, VBS is an integral part of Microsoft's ASP ( Active Server Pages ). The VBS code is integrated into an HTML page with the file extension ASP. The Web Service Internet Information Services , interprets the ASP file as a program and returns the result to the client (for example, the browser a website visitor) from. In this way, for. B. a database is queried, the result of which is processed and output - usually as an HTML file.

ASP is thus in competition with concepts such as PHP . The Microsoft web server service IIS is comparable to the Apache web server . In the meantime, the concept described above is also referred to as "Classic ASP" in order to differentiate it from the successor products (see also the section on the outlook).

Future use of VBScript

VBScript is still supported by Microsoft as a system component of all current Windows versions. However, the language itself has not been further developed for a long time. Hence, it is sometimes viewed as "dead language". Microsoft also offers various successor products and favors their use; This can also be seen in the fact that Microsoft's WSH-related websites are disappearing. However, due to the comparatively high acceptance of the old products and the widespread use of solutions based on them, they will still spend a considerable amount of time in coexistence.

  • In the area of ​​web servers, ASP.NET should take over the tasks of the so-called "Classic ASP", and the programming language Visual Basic .NET should replace VBS.
  • Windows PowerShell now exists to support administrative tasks , so it can be used as a successor product to Windows Script Host.
  • The free Visual Studio Express editions are also available for the implementation of extensive and complex programs .



The main advantages of the language are:

  • available on all Windows operating systems from 2000 / 98SE (with IE 4 also from Windows 95);
  • small file sizes as the language is interpreted by the operating system or browser;
  • Previous knowledge of the languages ​​Visual Basic (VB) and VBA make it easier to get started with VBS;
  • Access to other applications and installed components (for example Microsoft Office programs) and their object model ;
  • Expandability through specially developed components (objects).


The disadvantages include:

  • no development environment (IDE) to support larger projects; The Script Debugger and Script Editor programs offered by Microsoft should rather be viewed as stopgaps;
  • no use outside of Microsoft products;
  • Incompatibility with other operating systems.


  • Compared to Visual Basic (VB) and Visual Basic for Applications (VBA), VBS has no data typing, there is only the Variant data type , which can save all other types.
  • The range of functions is further reduced compared to VB.
  • Classes can be created.
  • As with JavaScript, the scripting host automatically processes the source text from the first line and until it encounters a functional or procedural instruction. A special identification of the automatically starting program part at the beginning, such as B. in C with 'int main ()', results in nothing being executed.
  • As with most scripting languages, the VBScript programs (scripts) are available as source text. It is therefore hardly possible to protect your own code from being viewed. The incidental display of the source code can be prevented by a simple type of encryption, either using an MS Script Encoder or an ActiveX control element ("Scripting.Encoder" object). Encrypted VBScript files have the extension .vbe(VBScript Encoded).


A simple VBScript for displaying a dialog window could look like this:

  MsgBox "Textinhalt des Fensters", 0, "Name des Fensters"

The second argument determines the appearance of the window. The value 0corresponds to a simple window that displays an OK button next to the text content , but there are other design options such as various buttons or symbols.

If, for example, this code is saved in a text file with the extension using the editor included in Windows .vbs, a double click is sufficient to execute it.


As a component of Internet Explorer, VBScript - like other active content - can pose an additional security risk if appropriately prepared websites can exploit an existing security gap. Such gaps were closed with Microsoft's updates from June 2020, for example. The risks can be avoided by preventing script execution in Internet Explorer or by using a different browser.

After Microsoft decided to also allow VBScript as part of HTML mails within Microsoft Outlook and Outlook Express , numerous viruses have spread through these applications using the initially insufficiently protected interface to ActiveX control elements. The potential danger here is not the special properties of VBScript, but the close connection of scripts with other system components. A similar risk is associated with PowerShell scripts, for example.

Since scripts are available as text files, their program character is sometimes overlooked. This can lead to underestimating their potential impact. The “Open” command does not load a script for editing either, but rather executes it.

Web links

Wikibooks: Visual Basic Script  - learning and teaching materials

Individual evidence

  1. MSDN forum: Accessing Win32 API in VBScript files - DLL function call using Excel macro
  2. Script component (freeware): WSH / VBS function extension DynaLib - DLL function call via COM object
  3. heise online: Browser cuts off old braids: IE 11 in future without activated VBScript. Retrieved August 4, 2019 .
  4. Download MS Script Encoder (via archive) ( Memento from July 18, 2012 in the Internet Archive )
  5. Microsoft Update Information: Security Update Guide, June 2020 Security Updates. Retrieved June 10, 2020 .