Generated by GPT-5-mini| VBScript | |
|---|---|
| Name | VBScript |
| Developer | Microsoft |
| First appeared | 1996 |
| Paradigm | Scripting, event-driven |
| Typing | Weak, dynamic |
| Influenced by | Visual Basic, BASIC |
| Influenced | Windows Script Host, ASP |
VBScript is a lightweight scripting language developed by Microsoft for automating tasks, extending applications, and scripting web pages on Microsoft platforms. It served as a scripting engine in Windows NT, Internet Explorer, and Active Server Pages environments, integrating with technologies from Microsoft Office to Windows Script Host. Over its lifecycle it intersected with developments from COM components, OLE Automation, and enterprise deployment tools such as System Center Configuration Manager.
VBScript was created at Microsoft in the mid-1990s to provide a subset of Visual Basic for scripting. It was released alongside Internet Explorer 3 and Windows 98 to enable client-side scripting in webpages and server-side scripting in Active Server Pages (ASP). Adoption was driven by integration with COM and Windows Script Host, while competition from Netscape Navigator, JavaScript, and later ECMAScript standards influenced its decline. Legal and standards discussions involving Netscape Communications and browser interoperability, plus shifts toward AJAX and ASP.NET, changed the scripting landscape.
The language exposes a syntax similar to Visual Basic and BASIC dialects, with statements like If..Then, For..Next, and Select Case. It supports variant typing through Variant (COM) types and provides direct access to COM objects such as Scripting.FileSystemObject and ADO for database access. Error handling uses On Error Resume Next and Err object patterns familiar to developers from Visual Basic 6.0. String manipulation, date functions, and interaction with OLE Automation types reflect heritage from Visual Basic and Microsoft Office macro models.
VBScript runs in several hosts: the Windows Script Host (wscript.exe, cscript.exe) for system automation, the Internet Explorer rendering engine for client-side scripting in legacy webpages, and Active Server Pages for server-side processing on Internet Information Services. Hosting often requires registration of COM scripting engines and integration with Windows Registry settings and Group Policy for enterprise deployment via System Center Configuration Manager. Third-party wrappers and engines attempted cross-platform hosting alongside Wine or embedding in C# and .NET Framework via interoperability layers.
Administrators used VBScript extensively for logon scripts, file management, and system configuration with tools like Active Directory, Windows Management Instrumentation, and Group Policy. Web developers used it for server-side templates in Active Server Pages and for legacy client-side behavior in Internet Explorer intranet applications. Automation of Microsoft Office applications—Word, Excel, Outlook—leveraged VBScript for mail merges, macros, and document generation through COM automation. Developers integrated VBScript with ADO for database connectivity to Microsoft SQL Server and legacy ODBC data sources.
VBScript's integration with COM and deep access to host resources made it a target in security incidents involving malware and phishing campaigns that exploited Windows Script Host execution. Browser vendors and enterprise security teams recommended disabling scripting in Internet Explorer and restricting execution via Group Policy and AppLocker controls. Language limitations include lack of strict typing, absence of modern constructs like closures and promises found in ECMAScript and constrained cross-platform support compared to JavaScript in Mozilla Firefox and Google Chrome. Deprecation in mainstream browsers and shifts toward .NET Framework and PowerShell reduced its role in modern deployments.
' Example: simple file write using FileSystemObject Dim fso, file Set fso = CreateObject("Scripting.FileSystemObject") Set file = fso.CreateTextFile("C:\example.txt", True) file.WriteLine "Hello from VBScript" file.Close
' Example: read registry value using WMI and COM Dim locator, service, colItems Set locator = CreateObject("WbemScripting.SWbemLocator") Set service = locator.ConnectServer(".", "root\cimv2") Set colItems = service.ExecQuery("SELECT * FROM Win32_OperatingSystem") For Each item In colItems Wscript.Echo item.Caption & " " & item.Version Next
' Example: ASP server-side snippet for database query (legacy) <% Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=SQLOLEDB;Data Source=SERVER;Initial Catalog=DB;Trusted_Connection=Yes;" Set rs = conn.Execute("SELECT TOP 1 Name FROM Users") Response.Write rs(0) rs.Close conn.Close %>
Category:Microsoft technologies