Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
VBScript
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|COM-based Visual Basic scripting language}} {{Infobox programming language | logo = [[File:VBSccript file format icon.png]] | file_ext = [[.vbs]], [[.vbe]], [[.wsf]], [[.wsc]] ([[Active Server Pages|.asp]], [[HTML Application|.hta]], [[.htm]], [[.html]]) | paradigm = | year = {{Start date and age|1996|5}} | designer = | developer = [[Microsoft]] | latest_release_version = 6.0 | latest_release_date = {{Start date and age|1998|9}} | latest_test_version = | latest_test_date = | typing = | implementations = [[Windows Script Host]], [[Active Server Pages]] | dialects = | influenced_by = [[Visual Basic (classic)|Visual Basic]] | influenced = [[Windows PowerShell]] | operating_system = [[Microsoft Windows|Windows]] | license = | website = https://learn.microsoft.com/previous-versions/t0aew7h6(v=vs.85) | wikibooks = }} '''VBScript''' ([[Microsoft]] [[Visual Basic (classic)|Visual Basic]] Scripting Edition) is a [[Deprecation|deprecated]] [[programming language]] for [[scripting language|scripting]] on [[Microsoft Windows]] using [[Component Object Model]] (COM), based on [[Visual Basic (classic)|classic Visual Basic]] and [[Active Scripting]]. It was popular with [[system administrator]]s for managing [[computer]]s and automating many aspects of computing environments, and has been installed by default in every desktop release of [[Microsoft Windows]] since [[Windows 98]];<ref>[http://msdn2.microsoft.com/en-us/library/x66z77t4(VS.85).aspx ''WSH Version Information''], on MSDN</ref> in [[Windows Server]] since [[Windows NT 4.0#Option Pack|Windows NT 4.0 Option Pack]];<ref>[http://msdn.microsoft.com/en-us/library/4y5y7bh5.aspx ''VBScript Version Information''], on MSDN</ref> and optionally with [[Windows CE]] (depending on the device it is installed on). VBScript running environments include: [[Windows Script Host]] (WSH), [[Internet Explorer]] (IE), and [[Internet Information Services]] (IIS).<ref>[http://msdn.microsoft.com/en-us/library/1kw29xwf.aspx ''What is VBScript?''], in MSDN Library</ref> The running environment is embeddable in other programs via the Microsoft Script Control ({{Mono|msscript.ocx}}). In October 2023, Microsoft announced that VBScript was deprecated.<ref>{{cite web |date=7 November 2023 |title=Deprecated features in the Windows client - What's new in Windows |url=https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features}}</ref> In May 2024, a multi-phase deprecation schedule was announced with removal planned for 2027 or later.<ref>{{Cite web |last=Shankar Chilla |first=Naveen |date=2024-05-22 |title=VBScript deprecation: Timelines and next steps |url=https://techcommunity.microsoft.com/t5/windows-it-pro-blog/vbscript-deprecation-timelines-and-next-steps/ba-p/4148301 |access-date=2024-05-28 |website=Microsoft Community Hub |language=en}}</ref> ==History== VBScript began as part of the Microsoft Windows Script Technologies, launched in 1996. This technology (which also included [[JScript]]) was initially targeted at web developers. During a period of just over two years, VBScript advanced from version 1.0 to 2.0, and over that time it gained support from Windows [[system administrator]]s seeking an automation tool more powerful than the [[batch file|batch language]] first developed in the early 1980s.<ref>''[[86-DOS]]''</ref> On August 1, 1996, [[Internet Explorer]] was released with features that included VBScript.<ref>{{cite web|url=http://www.johnsmiley.com/visualbasic/vbhistory.htm|title=The History of Visual Basic|website=www.johnsmiley.com}}</ref> In version 5.0, the functionality of VBScript was increased with new features including [[regular expression]]s; [[class (computer science)|classes]]; the ''With'' statement;<ref>[http://msdn2.microsoft.com/en-us/library/zw39ybk8.aspx ''Visual Basic Scripting Edition: With Statement''], on MSDN</ref> the ''Eval'', ''Execute'', and ''ExecuteGlobal'' functions to evaluate and execute script commands built during the execution of another script; a function-pointer system via GetRef,<ref>[http://msdn2.microsoft.com/en-us/library/ekabbe10.aspx ''GetRef Function''], on MSDN</ref> and [[Distributed Component Object Model|Distributed COM]] (DCOM) support. In version 5.5, ''SubMatches''<ref>[http://msdn2.microsoft.com/en-us/library/y27d2s18.aspx ''Visual Basic Scripting Edition: SubMatches Collection''], on MSDN</ref> were added to the ''regular expression'' class in VBScript, to finally allow script authors to capture the text within the expression's groups. That capability had already been available in JScript. With the advent of the [[.NET Framework]], the scripting team decided to implement future support for VBScript within [[ASP.NET]] for web development,<ref>[http://msdn.microsoft.com/en-us/library/ms974588.aspx#scripting0714_topic1 ''What About VBScript?''], within the article ''Introducing JScript .NET'' by Andrew Clinick of Microsoft Corporation, in Scripting Clinic on MSDN (July 14, 2000)</ref> and therefore no new versions of the VBScript engine would be developed. It would henceforth be supported by Microsoft's ''Sustaining Engineering Team'', who are responsible for bug fixes and security enhancements. For Windows system administrators, Microsoft suggests migrating to [[Windows PowerShell]], as VBScript is deprecated and will eventually be removed from Windows. ==Environments== ===Client-side web=== In a web page loaded by [[Internet Explorer]], VBScript is similar in function to [[JavaScript]]. The VBScript code in the HTML is logic that interacts with the [[Document Object Model]] (DOM) of the page {{endash}} allowing for functionality not possible in HTML alone. However, other web browsers such as [[Google Chrome|Chrome]], [[Firefox]] and [[Opera (web browser)|Opera]] do not support VBScript. Therefore, when client-side scripting and cross-browser compatibility are required, developers usually choose JavaScript due to its wide cross-browser compatibility. ===Active server page=== VBScript is used for server-side web page functionality via [[Active Server Pages]] (ASP). The ASP engine, {{Mono|asp.dll}}, invokes {{Mono|vbscript.dll}} to run VBScript scripts. VBScript that is embedded in an ASP page is contained within <% and %> context switches. The following example displays the current time in 24-hour format. <syntaxhighlight lang="aspx-vb" line="1"> <% Option Explicit %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>VBScript Example</title> </head> <body> <div><% ' Grab current time from Now() function. ' An '=' sign occurring after a context switch (<%) is shorthand ' for a call to the Write() method of the Response object. Dim timeValue : timeValue = Now %> The time, in 24-hour format, is <%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>. </div> </body> </html> </syntaxhighlight> ===Windows script host=== VBScript can run directly in the operating system via the [[Windows Script Host]] (WSH). A script file, usually with [[file extension|extension]] <code>.vbs</code> can be run either via {{Mono|Wscript.exe}} for [[graphical user interface]] (GUI) or {{Mono|Cscript.exe}} for [[command line interface]] (CLI). ===Windows script file=== A [[Windows Script File]] (WSF), styled after XML, can include multiple VBS files and is therefore a library of VBScript code that can be reused in a modular way. The files have extension <code>.wsf</code> and can be executed using {{Mono|wscript.exe}} or {{Mono|cscript.exe}}, as with a <code>.vbs</code> file. ===HTML Application=== An [[HTML Application]] (HTA) is styled after HTML. The HTML in the file is used to generate the user interface, and a scripting language such as VBScript is used for the program logic. The files have extension <code>.{{Not a typo|hta}}</code> and can be executed using {{Mono|mshta.exe}}. ===Windows Script Component=== VBScript can also be used in a Windows Script Component, an ActiveX-enabled script class that can be invoked by other COM-enabled applications.<ref>[http://msdn2.microsoft.com/en-us/library/07zhfkh8(VS.85).aspx ''Introducing Windows Script Components''], on MSDN</ref> These files have extension {{Mono|.wsc}}. ==Functionality== ===Language features=== The VBScript language is modeled on classic Visual Basic.<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/273zc69c(v=VS.85).aspx|title=VBScript Features|website=msdn.microsoft.com|date=24 October 2011 }}</ref> Notable features include: A "procedure" is the main construct in VBScript for separating code into smaller modules. VBScript distinguishes between a function, which can return a result in an assignment statement, and a subroutine, which cannot. Parameters are positional, and can be passed by value or by reference. Control structures include the usual iterative and conditional Do Loops, If-Then-Else statements, and Case statements, with some more complex variants, such as ElseIf and nested control structures. As a memory aid in coding, and certainly for readability, there are a large number of constants, such as True and False for logical values, vbOKCancel and vbYesNo for MsgBox codes, vbBlack and vbYellow for color values, vbCR for the carriage return character, and many others. Variables have "[[Variant type (COM)|Variant]]" type by default, but it is possible (and sometimes necessary) to force a particular type (integer, date, etc.) using conversion functions (CInt, CDate, etc.) User interaction is provided through the functions <code>MsgBox</code> and <code>InputBox</code> which provide a simple dialogue box format for messages and input. Both functions display prompting messages, with the former returning a standard response, and the latter returning one user-supplied text or numeric value. For more elaborate GUI interaction with controls, VBScript can be used in combination with HTML, for example, in an [[HTML Application]]. Event-driven forms are not supported as in Visual Basic or [[Visual Basic for Applications]]. Names are not case-sensitive. However, it is considered a best practice of VBScript style to be consistent and to capitalize judiciously. ===VBScript functionalities=== When hosted by the [[Windows Script Host]], VBScript provides numerous features which are common to scripting languages, but not available from [[Visual Basic 6.0]]. These features include: * Named and unnamed command line arguments * [[Stdin]] and [[stdout]], which could be redirected * WSH.Echo which writes to the console and cannot be redirected * WSH.ExitCode which can be tested from DOS batch files, or by the process which invoked the script file * Network printers * Network shares * Special folders, e.g. Desktop, Favorites, MyDocuments and so on * Network user information, such as group membership * Methods for runtime execution of text defined at runtime: Eval and Execute * Methods for executing scripts on remote machines * [[Windows Management Instrumentation]] (WMI) * Functionality for embedding a VBScript engine in other applications, using a widely known language CScript, the command line runner, provides options for: * Interactive or batch mode * Invoking debug mode from the command line * Error reporting including the line number === Additional functionality === File system management, file modification, and streaming text operations are implemented with the Scripting Runtime Library <code>scrrun.dll</code>. This provides objects such as FileSystemObject, File, and TextStream, which expose the Windows file system to the programmer. Binary file and memory I/O are provided by the "ADODB.Stream" class, which can also be used for string builders (to avoid excessive string concatenation, which can be costly), and to interconvert byte arrays and strings. Database access is made possible through [[ActiveX Data Objects]] (ADO), and the IIS Metabase can be manipulated using the GetObject() function with sufficient permissions (useful for creating and destroying sites and virtual directories). XML files and schemas can be manipulated with the [[MSXML|Microsoft XML Library]] [[Application Programming Interface]]s ({{Mono|msxml6.dll}}, {{Mono|msxml3.dll}}), which also can be used to retrieve content from the World Wide Web via the XMLHTTP and ServerXMLHTTP objects (class strings "MSXML2.XMLHTTP.6.0" and "MSXML2.ServerXMLHTTP.6.0", respectively). Functionality can also be added through ActiveX technologies. Security concerns have led to many ActiveX controls being blacklisted in the Internet Explorer process by Microsoft, which deploys the [[killbit]] via monthly Windows security updates to disable vulnerable Microsoft and third party code.<ref>{{cite web|url=http://support.microsoft.com/kb/240797|title=How to stop an ActiveX control from running in Internet Explorer|date=2007-08-24|access-date=2009-06-29|publisher=[[Microsoft]]}}</ref><ref>{{cite web|url=http://www.microsoft.com/technet/security/advisory/960715.mspx|title=Microsoft Security Advisory (960715): Update Rollup for ActiveX Kill Bits|date=2009-01-17|access-date=2009-06-29|publisher=[[Microsoft]]}}</ref> Programmers can utilize the extensibility via COM (ActiveX) modules to specifically equip the Script Host and VBScript with required or desired functions. The "VTool" component, for instance, adds a number of dialog windows, binary file access, and other functionality.<ref>[http://eriedel.info/en/files/vtool/vtool.html "VTool" script component] – GUI and functional enhancements for WSH/VBS</ref> ==Development tools== Microsoft does not routinely make available an IDE ([[Integrated Development Environment]]) for VBScript, although the [[Microsoft Script Editor]] has been bundled with certain versions of Microsoft Office. For debugging purposes the [[Microsoft Script Debugger]] can still be used in current Windows versions, even though the tool has not been updated in years. It allows the user to set break points in the VBScript code but the user interface is more than clumsy. There are VBScript debuggers available from third-party sources,<ref>{{cite web|url=http://www.vbsedit.com/|title=VbsEdit - VBScript Editor with Debugger - VBS Editor|website=www.vbsedit.com}}</ref><ref>{{cite web|url=http://www.remotedebugger.com/vbs_debugger/vbs_debugger.asp|title=SplineTech VBS Debugger, VBScript Debugger. Debug VBS.|first=Spline Technologies|last=Corp.|website=www.remotedebugger.com}}</ref> and many [[list of text editors|text editors]] offer [[syntax highlighting]] for the language. During execution, when an error occurs, the script host issues a message stating the type of error and the number of the offending line. == Uses == Although VBScript is a general-purpose scripting language, several particular areas of use are noteworthy. First, it used to be widely used among system administrators in the Microsoft environment,<ref>[https://technet.microsoft.com/en-us/scriptcenter/default.aspx Script Center], Microsoft web site targeting system administration scriptors</ref> but it has since been vastly surpassed by [[PowerShell]]. Second, VBScript is the scripting language for [[UFT One|OpenText UFT One]], a test automation tool.<ref>{{cite web|url=http://knol.google.com/k/quick-test-professional-software-test-automation-tool#Basics_of_vbscript|title=''Quick Test Professional – Basics of VBScript''|access-date=2010-05-05|archive-date=2010-02-17|archive-url=https://web.archive.org/web/20100217055646/http://knol.google.com/k/quick-test-professional-software-test-automation-tool#Basics_of_vbscript|url-status=dead}}</ref> A third area to note is the adoption of VBScript as the internal scripting language for some embedded applications, such as industrial operator interfaces and human machine interfaces. The hierarchical DBMS [[InterSystems]] [[Caché (software)|Caché]] (which has its roots in the language [[MUMPS]]) also supports an implementation of VBScript, Cache BASIC, for programming stored code.<ref>{{cite web|url=http://www.intersystems.com/cache/technology/components/script/index.html |title=Caché for Unstructured Data Analysis |publisher=InterSystems |access-date=2018-09-24}}</ref> VBScript omits several useful features of the full Visual Basic, such as strong typing, extended error trapping and the ability to pass a variable number of parameters to a subroutine. However, its use is relatively widespread because it is easy to learn and because those who implement code in the language need not pay royalties to Microsoft as long as the VBScript trade mark is acknowledged.{{Citation needed|date=September 2014}} When an organization licenses [[Visual Basic for Applications]] (VBA) from Microsoft, as companies such as Autodesk, StatSoft, Great Plains Accounting and Visio (subsequently acquired by Microsoft) have done, it is allowed to redistribute the full VBA code-writing and debugging environment with its product. VBScript is used in place of VBA as the macro language of Outlook 97. VBScript can be effectively used for automating day to day office tasks as well as monitoring in the Windows-based environment. It can also be used in collaboration with ADODB [[ActiveX Data Objects]] (ADODB) for effective database connectivity. VBScript can also be used to create [[malware]] and viruses, such as the [[ILOVEYOU]] worm that spread through email attachment in Outlook 97 that cost billions of dollars. ==See also== * [[AppleScript]] * [[FastTrack Scripting Host]] * [[HTML Components]] * [[JavaScript]] * [[JScript .NET]] * [[JScript]] * [[PerlScript]] * [[Windows PowerShell]] * [[Windows Script File]] ==References== {{Reflist}} ==External links== {{Commons category}} {{Wikibooks|VBScript Programming}} * [https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/d1wf56tt(v=vs.84) VBScript Language Reference], Microsoft Docs * [https://isvbscriptdead.com Is VBScript Dead?], isvbscriptdead.com * [https://ss64.com/vb/ VBScript Commands], ss64.com * [https://ss64.com/vb/syntax.html VBScript How-to guides and examples], ss64.com * [https://technet.microsoft.com/en-us/library/ee198925.aspx WMI Overview], Microsoft TechNet {{Microsoft Windows components}} {{Microsoft development tools}} {{Internet Explorer}} {{BASIC}} {{Authority control}} [[Category:BASIC programming language family]] [[Category:Internet Explorer]] [[Category:Microsoft programming languages]] [[Category:Programming languages created in 1996]] [[Category:Scripting languages]] [[Category:Windows components]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Authority control
(
edit
)
Template:BASIC
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite web
(
edit
)
Template:Commons category
(
edit
)
Template:Endash
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Internet Explorer
(
edit
)
Template:Microsoft Windows components
(
edit
)
Template:Microsoft development tools
(
edit
)
Template:Mono
(
edit
)
Template:Not a typo
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Wikibooks
(
edit
)