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
(section)
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!
==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>
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)