VBScript - All Commands Cheat Sheet

VBScript - All Commands Cheat Sheet

A C D E F G H I J L M N O R S T U W Y

Misc

‘ Remark The Remark command outputs comments and instructions in the VBScript code.
.AddPrinterConn The .AddPrinterConn command in VB Script establishes a connection to a printer or a print queue.
.AppActivate .AppActivate activates a specified window and its application.
.Application The .Application object in VB Script is a powerful tool that provides access to the global state of the VB Script runtime environment.
.BrowseForFolder The .BrowseForFolder command in VB Script allows users to open a file browser window and select a directory.
.CreateObject The .CreateObject command in VB Script is used to create an instance of an ActiveX object.
.CreateShortcut .CreateShortcut creates a shortcut to a specified file, folder, or website on the user's desktop.
.CurrentDirectory The .CurrentDirectory command in VB Script returns the full path of the current working directory.
.Echo The .Echo command in VBScript is used to display a message on the screen or write it to a specified output device.
.EnumPrinterConnections
.Exec .Exec executes a program or command in a new process.
.GetObject .GetObject command in VB Script creates an object that references another object or application.
.LogEvent The .LogEvent command logs a custom event to the Windows Event Log.
.MapNetworkDrive MapNetworkDrive establishes a connection to a shared network drive and maps it to a local drive.
.Quit The .Quit command in VB Script enables the graceful termination of a script.
.ReadLine The ".ReadLine" command in VB Script allows you to read a single line of text from the standard input (usually the keyboard).
.RegDelete The .RegDelete command removes a specified key from the Windows registry.
.RegRead The .RegRead command in VB Script allows you to read values from the Windows Registry, a hierarchical database that stores system configuration settings.
.RegWrite Writes a value or key to the Windows Registry, modifying the system or user registry.
.RemovePrinterConnection
.Run The Run command executes a program or opens a document.
.SendKeys The .SendKeys command allows you to simulate keystrokes and input text into any active application from within VB Script.
.SetDefaultPrinter .SetDefaultPrinter sets the default printer for the current user.
.Shell The .Shell method lets VBScript seamlessly execute programs and scripts directly from within your scripts.
.ShellExecute
.Sleep The .Sleep command in VB Script executes a time delay or pause in the script's execution.
.SpecialFolders .SpecialFolders function in VB Script provides a way to access special folders on the local computer, such as the desktop, My Documents, or the Windows directory.

A

Abs The Abs command in VBScript calculates the absolute value of a number, effectively removing its negative sign if present.
Arguments The Arguments object provides access to command-line arguments passed to a VB Script.
Array The Array() command in VB Script allows you to create an array, a data structure that can store a collection of values of the same type.
Asc The Asc function returns the American Standard Code for Information Interchange (ASCII) code for the first character of a string.
AscB The AscB command in VB Script is used to retrieve the ASCII code of the first character in a specified string.
AscW The AscW command in VB Script returns the ASCII code of the first Unicode character in a string.

C

CBool
CByte The CByte command in VB Script converts a numeric expression to a Byte value.
CCur CCur converts a string expression to a currency value.
CDate The CDate command in VB Script converts a string representing a date and time expression into a Date object.
CDbl The CDbl() command converts a numeric string to a double-precision floating-point number.
Chr The Chr command in VBScript converts an ASCII code to its corresponding character.
ChrB The ChrB command in VB Script is used to convert an ASCII or Unicode character code into its corresponding character.
ChrW The ChrW command in VBScript converts Unicode character codes to their wide character counterparts.
CInt The CInt command converts a string representation of an integer into a numeric data type.
CLng CLng converts a numeric expression to a Long integer (32-bit integer).
Command The Command command in VB Script executes a system command, allowing access to various operating system functionalities.
cscript cscript is a command-line utility that executes scripts written in VBScript.
CSng The CSng command in VB Script is a conversion function that changes a string to a Single-precision floating-point number.
CStr CStr is a VB Script command used to convert data to a string.

D

Date Date is a VB Script command that returns the current system date and time in a customizable format.
DateAdd The DateAdd function in VB Script allows you to perform basic date and time arithmetic, such as adding or subtracting a specified number of days, months, years, hours, minutes, or seconds from a given date or time.
DateDiff The DateDiff command in VB Script allows you to find the difference between two dates, expressed as a number representing the specified interval.
DatePart DatePart can be combined with other VB Script functions to perform complex date calculations.
DateSerial DateSerial calculates a date from specified year, month, and day integers.
DateValue
Day The Day command in VB Script retrieves the day of the month for a given date object.
Dim The Dim command is used to declare and optionally initialize variables in VB Script.
Do..Loop The Do..Loop command in VB Script creates a loop structure for executing a set of statements repeatedly until a specified condition is met.
Drives The Drives command in VB Script returns an array of drive letters that are available on the computer.

E

Environment Variables The Environment Variables command in VB Script enables manipulation of environment variables.
Escape Double Escaping: Be cautious of double-escaping strings that have already been escaped.
Eval Eval evaluates an expression as a VB Script code and returns the result.
Execute The Execute command executes the specified command line or batch file.
Exit Exit command terminates the execution of the current script or function in VBScript.
Exp The Exp function in VB Script calculates the exponential of a given number, which is the value of e (approximately 2.71828183) raised to the power of the input.

F

FileSystemObject FileSystemObject (FSO) is a VB Script utility that provides robust and comprehensive file system manipulation capabilities.
Filter The Filter() function in VBScript allows you to search through a string or array and extract specific elements based on a specified condition.
Fix The Fix command in VB Script corrects the pointer to the currently active Automation server or control.
For Each… For Each... iterates through the elements of a collection, performing an action for each item.
For…Next The For...Next command in VBScript is used for looping through a sequence of values or executing a block of code multiple times.
FormatCurrency The FormatCurrency command in VBScript is utilized to format a numeric value as a currency string.
FormatDateTime The FormatDateTime command in VB Script allows you to format a date or time value into a custom string representation.
FormatNumber The FormatNumber command in VBScript is used to convert a numeric value into a string representation with the specified number formatting options.
FormatPercent FormatPercent can be combined with other VB Script functions to perform complex formatting tasks.
Function The Function command in VB Script allows you to define user-defined functions or subroutines within a script.

G

GetLocale The GetLocale() function returns a string representing the current user locale identifier.

H

Hex The Hex command in VB Script converts an integer value to a hexadecimal string representation.
Hour The Hour command in VB Script retrieves the hour (0 - 23) component of the current time.

I

If..Then The If..Then command in VBScript is used for conditional execution, allowing you to execute specific code blocks only if certain conditions are met.
InputBox The InputBox command prompts the user for input via a modal dialog box.
InStr The InStr command finds the first occurrence of a specified substring within a string.
InStrRev
Int Int converts a number to an integer (whole number).
IsArray The IsArray command in VB Script provides a way to determine if a variable is an array.
IsDate This function determines whether a string represents a valid date.
IsEmpty IsEmpty is a VB Script command used to evaluate whether a variable or object has a value or not.
IsNull The IsNull command in VB Script evaluates whether a given expression or variable is null.
IsNumeric The IsNumeric command in VB Script checks if a given value can be converted to a number (Double).
IsObject The IsObject command in VB Script examines a given value and determines whether it represents an object.

J

Join The Join method combines two or more strings into a single string, separating them with a specified delimiter.

L

LBound This occurs when you try to access an element outside the valid range of the array.
LCase The LCase command converts all characters in a string to lowercase.
Left The Left function in VB Script extracts a specified number of characters from the left side of a string.
Len The Len command in VB Script returns the number of characters in a string variable.
Log The Log command in VB Script calculates the natural logarithm of a number.
LTrim The LTrim command in VB Script removes leading whitespace characters (spaces, tabs, carriage returns, line feeds) from a string.

M

Mid The Mid command in VB Script allows you to extract a substring from a given string.
Minute The Minute command in VB Script extracts the minute component from a specified date value.
Month The Month command in VB Script returns the month component of a date as an integer between 1 and 12.
MonthName
MsgBox MsgBox command in VB Script displays a message box with a specified text, title, and buttons.

N

Network The Network command establishes and manages network connections in VB Script.
Now The Now function in VB Script returns the current system date and time as a Date object.

O

On Error The On Error command in VB Script enables customized error handling, allowing you to define how the script responds to errors.

R

ReDim The ReDim statement in VBScript dynamically redimensions an array to a new size or shape.
REM The REM command in VBScript is used to insert comments into your script.
Replace The Replace command in VB Script performs a search and replace operation on a given string.
RGB The RGB command in VB Script is used to create a color value from the specified red, green, and blue components.
Right Right function extracts a specified number of characters from the right end of a string.
Rnd The Rnd command generates a random number.
Round Round is a VB Script command used for rounding numeric values to specified decimal places or the nearest integer.
RTrim The RTrim command removes all trailing spaces from a string.

S

Second VB Script's Second command retrieves the second component of a time value.
Select…Case The Select...Case command allows conditional branching of code flow based on the value of a specified expression.
Set The Set command in VB Script is utilized to assign an object to a variable.
SetLocale The SetLocale command in VB Script allows you to set the current locale of your script.
Sgn The Sgn command in VBScript determines the sign of a given numeric expression.
Space The Space command in VBScript creates a string of a specified number of spaces.
Split The Split command in VB Script is used to divide a string into an array of substrings based on a specified delimiter.
Sqr The Sqr command in VB Script calculates the square root of a specified numeric expression.
StdOut.Read The StdOut.Read() command in VB Script reads data from the standard output stream (stdout), which is typically generated by scripts, programs, or processes running in a command prompt or PowerShell.
StdOut.Write
StrComp The StrComp command in VB Script compares two strings and returns a numeric value indicating their relative order.
String The VB Script String command creates a new string object, which can be used to manipulate and store text data.
StrReverse StrReverse is a VB Script command used to reverse the order of characters in a string.
Sub The Sub command in VB Script marks the beginning of a subroutine, a reusable block of code within a script.

T

Time The Time command in VBScript provides the current system time as a string.
TimeSerial The TimeSerial command in VB Script constructs a time value from specified hour, minute, and second values.
TimeValue The TimeValue function converts a string representing a time value into a Date object.
Trim
TypeName The TypeName command in VB Script returns a string representing the VBA type of a variable, object, or expression.

U

UBound UBound retrieves the upper bound subscript of an array, specifying the last index value that can be used to access the array.
UCase The UCase command in VB Script converts all lowercase characters in a given string to uppercase.
UnEscape UnEscape is a VB Script command used to decode HTML or URL encoded strings, converting them back to their original characters.

W

Weekday The Weekday command in VB Script returns the day of the week for a given date.
WeekdayName The WeekdayName command in VB Script retrieves the full name of a specified numeric weekday, typically from 1 to 7.
While…Wend The While...Wend command in VBScript allows for repeated execution of a block of code until a specified condition becomes false.
With With creates a contextual scope for setting and getting properties and methods of an object.

Y

Year The Year function in VBScript extracts the year as a four-digit integer from a given date value.