VBScript command

Must Watch!



MustWatch

https://ss64.com/vb/


How-to: VBScript command line arguments

Positional arguments

Calling a script with unnamed arguments is a simple method of passing values into a VBScript, those values can then be picked up within the script by reading the properties of WScript.Arguments cscript.exe demo.vbs December 500 [demo.vbs] strMonth = WScript.Arguments.Item(0) strPrice = WScript.Arguments.Item(1) wscript.echo strMonth & " and " & strPrice This can be extended to cope with a large number of arguments .Item(n) but every time the script is called all of the arguments must be present and passed in the same order. If any are missed out then the numbers will change .Item(4) becomes .Item(3)etc. The Unnamed property will return a collection of the positional arguments, presented in the order that they were entered on the command line. Set myArgs = WScript.Arguments.Unnamed For i = 0 to myargs.count -1 wscript.Echo "Argument" & i & " = " & myArgs.item(i) Next Passing an argument that starts with “//” to a VBscript, will by default be taken as options for the windows script host itself (cscript or wscript). To avoid this pass a double slash "//" to end the argument parsing of cscript/wscript. Alternatively use a named argument as below.

Named arguments

A named argument begins with a slash (/), and the name and the value are separated by a colon (:) those values can then be picked up within the script by reading the collection WScript.Arguments.Named cscript.exe demo2.vbs /month:April /price:500 [demo2.vbs] Set colArgs = WScript.Arguments.Named strMonth = colArgs.Item("month") strPrice = colArgs.Item("price") wscript.echo strMonth & " and " & strPrice Named arguments can be given in any order cscript.exe demo2.vbs /price:500 /month:April Named arguments are optional, so you can include a default: If colArgs.Exists("month") Then strMonth = colArgs.Item("month") Else strMonth = "January" End If To count the number of arguments: intCount = WScript.Arguments.Count wscript.echo intCount
“Art, in itself, is an attempt to bring order out of chaos” ~ Stephen Sondheim

How-to: VBScript Looping statements

Looping Through Code, Looping allows you to run a group of statements repeatedly. Do Loop Do...Loop to run a block of statements While a Condition is True Do While IntMyInteger > 10 IntMyInteger = IntMyInteger - 1 Loop or Do IntMyInteger = IntMyInteger - 1 Loop While IntMyInteger > 10 Do...Loop to run a block of statements Until a Condition Becomes True Do Until IntMyInteger = 10 IntMyInteger = IntMyInteger - 1 Loop or Do IntMyInteger = IntMyInteger + 1 Loop Until IntMyInteger = 10 Exit a Do...Loop from inside the Loop with the Exit Do statement. For...Next For...Next to run statements a specific number of times. For IntMyInteger = 1 To 50 MyProcedure Next This can be modified with a positive or negative Step value For IntMyInteger = 50 To 1 step -5 MyProcedure Next Exit a For...Next statement prematurely with the Exit For statement. For Each...Next A For Each...Next loop repeats a group of statements for each item in a collection of objects or for each element of an array. While...Wend Conditionally repeat a block of statements: While second(Time()) > 30 WScript.Echo "This line will repeat for 30 seconds" Wend “It's a good rule to follow the first law of holes: If you are in one, stop digging” ~ Denis Healey

How-to: VB Script Operators

Arithmetic Exponentiation ^ Unary negation - Multiplication * Division / Integer division \ Modulus arithmetic Mod Addition + Subtraction - String concatenation & Comparison Equality = Inequality <> Less than < Greater than > Less than or equal to <= Greater than or equal to >= Object equivalence Is Logical Logical negation Not Logical conjunction And Logical disjunction Or Logical exclusion Xor Logical equivalence Eqv Logical implication Imp Related VBScript Operators - Docs.Microsoft.com “Free lunches don't come cheap” - Charles Petzold (Author of Programming Windows)

And

Returns TRUE if and only if both of the operands are true. Syntax result = expression1 And expression2 how result is determined:
If expression1 is And expression2 is The result is
True True True
True False False
True Null Null
False True False
False False False
False Null False
Null True Null
Null False False
Null Null Null
Example If (1 + 2 = 3) and (2 + 2 = 4) Then WScript.Echo "It worked" End If “Success is falling nine times and getting up ten” ~ Jon Bon Jovi

Or

Returns TRUE if and only if one or more of the operands is true. Syntax result = expression1 Or expression2 how result is determined:
If expression1 is And expression2 is The result is
True True True
True False True
True Null True
False True True
False False False
False Null Null
Null True True
Null False Null
Null Null Null
Example If (2 + 2 = 5) Or (2 + 2 = 4) Then WScript.Echo "It worked" End If “In the sky there is no distinction of east and west; people create the distinctions out of their own minds and then believe them to be true” ~ Bukkyo Dendo Kyonkai

How-to: VB Script Variables

Create a Variable with 'Dim' in a procedure, Function or Property statement. When assigning a value to a variable, strings are enclosed in quotes (") Dates and times are enclosing in number signs (#)
Examples: Dim StrMyTextString Dim IntMyInteger Dim MyArray(10) Then assign values: IntMyInteger = 200 StrMyTextString = "This is an example string" To declare variables explicitly, place the Option Explicit statement as the first statement in your script. Once this is in place all variables must be defined before being used, and attempting to use an undefined variable will raise an error. This means that a typo in a variable name will immediately raise an error rather than being silently ignored. Although you can choose a variable name to indicate the data type, all VBScript variables are type: variant.

Public variables

Defined at the Script-level a public Variable is available throughout the entire script. This includes all functions and subroutines. Syntax: Public variableName[([subscripts])][, variableName[([subscripts])]] ... Key: subscripts The dimensions of an array variable; up to 60 multiple dimensions may be declared. upper [, upper] ... Where upper is the upper bound of the array, The lower bound of an array is always zero. Examples: Public StrMyVariantString, IntMyVariantInteger, anotherVariable Public MyArray(10) Then assign values: MyArray(2,4) = 25 StrMyVariantString = "This is an example string"

Private variables

Defined at the Script-level, a Private variable is available only to the script in which they are declared. They are not inherited by any functions or subroutines. Syntax: Private variableName[([subscripts])][, variableName[([subscripts])]] . . . Key: subscripts The dimensions of an array variable; up to 60 multiple dimensions may be declared. upper [, upper] ... Where upper is the upper bound of the array, The lower bound of an array is always zero. Examples: Private StrMyVariantString, IntMyVariantInteger, anotherVariable Private MyArray(10)

Constants - the Const statement.

Constants are fixed values which once defined, cannot be changed. For example: Const MY_STRING = "This is my string." Const MY_PERCENTAGE = 75 Const DATE_OF_BIRTH = #6-1-97# By convention the Constant name is always in UPPER CASE. “Whether you think you can or think you can't — you are right” ~ Henry Ford Related Array Variables - VBScript array variables. Set variable = object - Assign an object reference.

How-to: VB Script Array Variables

An array variable can be created either locally with 'Dim', or as a public or private variable.

One dimensional Array

The maximum size of the array is determined by the subscript value in brackets: DIM variableName(subscript) Example: Dim arrCoffee(2) arrCoffee(0) = "Expresso" arrCoffee(1) = "Latte" arrCoffee(2) = "Cappuchino" wscript.echo arrCoffee(2) The lower bound of an array is always zero, so in the above example the subscript is 2 yet the array holds 3 items.

Two dimensional Array

A 2 dimensional array can be thought of as like a spreadsheet with X rows and Y columns, each holding one value. The definition has 2 subscripts for X and Y: DIM varname(SubscriptX, SubscriptY) Example: Dim arrCoffee(2,1) arrCoffee(0,0) = "Expresso" arrCoffee(0,1) = "No" arrCoffee(1,0) = "Latte" arrCoffee(1,1) = "Yes" arrCoffee(2,0) = "Cappuchino" arrCoffee(2,1) = "Yes" wscript.echo "Coffee: " + arrCoffee(2,0) + " Milk: " + arrCoffee(2,1)

Multi dimensional Array

A multi dimensional array can be constructed just like a 2 dimensional one, adding extra subscripts for each extra dimension up to a maximum of 600. DIM varname(SubscriptX, SubscriptY, SubscriptZ...)
“Working in an office with an array of electronic devices is like trying to get something done at home with half a dozen small children around. The calls for attention are constant” ~ Marilyn vos Savant Related Variables - Define VBScript variables. Set variable = object - Assign an object reference.

How-to: VBScript Built-In Constants

These constants are built-in to VBScript, each string represents a number. vbAbort 3 vbAbortRetryIgnore 2 vbApplicationModal 0 vbArray 8192 vbBinaryCompare 0 vbBlack 0 vbBlue 16,711,680 vbBoolean 11 vbByte 17 vbCancel 2 vbCr Chr(13) vbCritical 16 vbCrLf Chr(13) vbCurrency 6 vbCyan 16,776,960 vbDataObject 13 vbDate 7 vbDecimal 14 vbDefaultButton1 0 vbDefaultButton2 256 vbDefaultButton3 512 vbDefaultButton4 768 vbDouble 5 vbEmpty 0 vbError 10 vbExclamation 48 vbFalse 0 (Logical FALSE is always zero) vbFirstFourDays 2 vbFirstFullWeek 3 vbFirstJan1 1 vbFormFeed Chr(12) vbFriday 6 vbGeneralDate 0 vbGreen 65280 vbIgnore 5 vbInformation 64 vbInteger 2 vbLf Chr(10) vbLong 3 vbLongDate 1 vbLongTime 3 vbMagenta 16,711,935 vbMonday 2 vbMsgBoxHelpButton 16384 vbMsgBoxRight 524288 vbMsgBoxRtlReading 1048576 vbMsgBoxSetForeground 65536 vbNewLine Chr(13) vbNo 7 vbNull 1 vbNullChar Chr(0) vbNullString 0 vbObject 9 vbObjectError -2147221504 vbOK 1 vbOKCancel 1 vbOKOnly 0 vbQuestion 32 vbRed 255 vbRetry 4 vbRetryCancel 5 vbSaturday 7 vbShortDate 2 vbShortTime 4 vbSingle 4 vbString 8 vbSunday 1 vbSystemModal 4096 vbTab Chr(9) vbTextCompare 1 vbThursday 5 vbTrue -1 (Logical TRUE is NOT false, so any non-zero value is true) vbTuesday 3 vbUseDefault -2 vbUseSystem 0 vbUseSystemDayOfWeek 0 vbVariant 12 (used only with arrays) vbVerticalTab Chr(11) vbWednesday 4 vbWhite 16,777,215 vbYellow 65535 vbYes 6 vbYesNo 4 vbYesNoCancel 3 “Find the seed at the bottom of your heart and bring forth a flower” ~ Shigenori Kameoka

How-to: Test for Empty or NULL or Zero [IsBlank function]

The IsBlank function below will return True if the variable or value passed to it is Empty or NULL or Zero. It will return False if the variable contains any string or a value other than '0'. Function IsBlank(Value) 'returns True if Empty or NULL or Zero If IsEmpty(Value) or IsNull(Value) Then IsBlank = True ElseIf VarType(Value) = vbString Then If Value = "" Then IsBlank = True End If ElseIf IsObject(Value) Then If Value Is Nothing Then IsBlank = True End If ElseIf IsNumeric(Value) Then If Value = 0 Then wscript.echo " Zero value found" IsBlank = True End If Else IsBlank = False End If End Function Arguably the numeric value '0' is as valid a value as any other number. The logic behind flagging this as blank is that you may have data like a Price or a Surname = 0 which most likely should be treated as being blank. All vbscript variables are variants. A Variant is a special kind of data type that can contain different kinds of information, depending on how it is used. Examples using the function above Wscript.echo "testing 0..." boolReturn = IsBlank(0) if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" Wscript.echo "testing 123..." boolReturn = IsBlank(123) if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" Wscript.echo "testing 100-100..." boolReturn = IsBlank(100-100) if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" Wscript.echo "testing null..." boolReturn = IsBlank(null) if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" Wscript.echo "testing empty string..." boolReturn = IsBlank("") if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" Wscript.echo "testing string..." boolReturn = IsBlank("The quick brown fox") if boolReturn = true then wscript.echo "It's Blank" else wscript.echo "not blank" “Let him that would move the world, first move himself” - Socrates

Function

Define a function procedure. Syntax [Public [Default] | Private ] Function name([arg_List]) [statements] [name=expression] Exit Function [statements] [name=expression] End Function Key Public Extend the scope of this function to all procedures in the project. Public Default Define a method as the default member of a class (Only for public functions defined within a class.) Private Restrict the scope of this function to procedures within the same module. name The name of the function. arg_List Argument variabless passed to the function, comma separated. By default, each local variable=argument (ByRef) To have each local variable=value of the argument prefix the argument with 'ByVal'. statements Program code expression The value to return. In VBScript, functions can be defined before or after the code that calls it. In many other languages (e.g. PowerShell) it is required to define the function before it is called. Placing the definitions first does have the advantage that the finished code can be read from top to bottom without having to jump up and down the page. Examples Function DemoFunc(Arg1, ByRef Arg2) ' Return the two arguments in a single string DemoFunc = "First: " & Arg1 & " second: " & Arg2 End Function 'Now call the function above myDemo = DemoFunc("Hello","World") wscript.echo myDemo “The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris Equivalent in PowerShell: Functions

VBScript Functions

This page contains all the built-in VBScript functions. The page is divided into following sections: Date/Time functions Conversion functions Format functions Math functions Array functions String functions Other functions

Date/Time Functions

FunctionDescription
CDateConverts a valid date and time expression to the variant of subtype Date
DateReturns the current system date
DateAddReturns a date to which a specified time interval has been added
DateDiffReturns the number of intervals between two dates
DatePartReturns the specified part of a given date
DateSerialReturns the date for a specified year, month, and day
DateValueReturns a date
DayReturns a number that represents the day of the month (between 1 and 31, inclusive)
FormatDateTimeReturns an expression formatted as a date or time
HourReturns a number that represents the hour of the day (between 0 and 23, inclusive)
IsDateReturns a Boolean value that indicates if the evaluated expression can be converted to a date
MinuteReturns a number that represents the minute of the hour (between 0 and 59, inclusive)
MonthReturns a number that represents the month of the year (between 1 and 12, inclusive)
MonthNameReturns the name of a specified month
NowReturns the current system date and time
SecondReturns a number that represents the second of the minute (between 0 and 59, inclusive)
TimeReturns the current system time
TimerReturns the number of seconds since 12:00 AM
TimeSerialReturns the time for a specific hour, minute, and second
TimeValueReturns a time
WeekdayReturns a number that represents the day of the week (between 1 and 7, inclusive)
WeekdayNameReturns the weekday name of a specified day of the week
YearReturns a number that represents the year

Conversion Functions

FunctionDescription
AscConverts the first letter in a string to ANSI code
CBoolConverts an expression to a variant of subtype Boolean
CByteConverts an expression to a variant of subtype Byte
CCurConverts an expression to a variant of subtype Currency
CDateConverts a valid date and time expression to the variant of subtype Date
CDblConverts an expression to a variant of subtype Double
ChrConverts the specified ANSI code to a character
CIntConverts an expression to a variant of subtype Integer
CLngConverts an expression to a variant of subtype Long
CSngConverts an expression to a variant of subtype Single
CStrConverts an expression to a variant of subtype String
HexReturns the hexadecimal value of a specified number
OctReturns the octal value of a specified number

Format Functions

FunctionDescription
FormatCurrencyReturns an expression formatted as a currency value
FormatDateTimeReturns an expression formatted as a date or time
FormatNumberReturns an expression formatted as a number
FormatPercentReturns an expression formatted as a percentage

Math Functions

FunctionDescription
AbsReturns the absolute value of a specified number
AtnReturns the arctangent of a specified number
CosReturns the cosine of a specified number (angle)
ExpReturns e raised to a power
HexReturns the hexadecimal value of a specified number
IntReturns the integer part of a specified number
FixReturns the integer part of a specified number
LogReturns the natural logarithm of a specified number
OctReturns the octal value of a specified number
RndReturns a random number less than 1 but greater or equal to 0
SgnReturns an integer that indicates the sign of a specified number
SinReturns the sine of a specified number (angle)
SqrReturns the square root of a specified number
TanReturns the tangent of a specified number (angle)

Array Functions

FunctionDescription
ArrayReturns a variant containing an array
FilterReturns a zero-based array that contains a subset of a string array based on a filter criteria
IsArrayReturns a Boolean value that indicates whether a specified variable is an array
JoinReturns a string that consists of a number of substrings in an array
LBoundReturns the smallest subscript for the indicated dimension of an array
SplitReturns a zero-based, one-dimensional array that contains a specified number of substrings
UBoundReturns the largest subscript for the indicated dimension of an array

String Functions

FunctionDescription
InStrReturns the position of the first occurrence of one string within another. The search begins at the first character of the string
InStrRevReturns the position of the first occurrence of one string within another. The search begins at the last character of the string
LCaseConverts a specified string to lowercase
LeftReturns a specified number of characters from the left side of a string
LenReturns the number of characters in a string
LTrimRemoves spaces on the left side of a string
RTrimRemoves spaces on the right side of a string
TrimRemoves spaces on both the left and the right side of a string
MidReturns a specified number of characters from a string
ReplaceReplaces a specified part of a string with another string a specified number of times
RightReturns a specified number of characters from the right side of a string
SpaceReturns a string that consists of a specified number of spaces
StrCompCompares two strings and returns a value that represents the result of the comparison
StringReturns a string that contains a repeating character of a specified length
StrReverseReverses a string
UCaseConverts a specified string to uppercase

Other Functions

FunctionDescription
CreateObjectCreates an object of a specified type
EvalEvaluates an expression and returns the result
IsEmptyReturns a Boolean value that indicates whether a specified variable has been initialized or not
IsNullReturns a Boolean value that indicates whether a specified expression contains no valid data (Null)
IsNumericReturns a Boolean value that indicates whether a specified expression can be evaluated as a number
IsObjectReturns a Boolean value that indicates whether the specified expression is an automation object
RGBReturns a number that represents an RGB color value
RoundRounds a number
ScriptEngineReturns the scripting language in use
ScriptEngineBuildVersionReturns the build version number of the scripting engine in use
ScriptEngineMajorVersionReturns the major version number of the scripting engine in use
ScriptEngineMinorVersionReturns the minor version number of the scripting engine in use
TypeNameReturns the subtype of a specified variable
VarTypeReturns a value that indicates the subtype of a specified variable

Call a Sub or Function Procedure

VBScript Procedures When you call a Function in your code, you do like this: name = findname() Here you call a Function called "findname", the Function returns a value that will be stored in the variable "name". Or, you can do like this: msgbox "Your name is " & findname() Here you also call a Function called "findname", the Function returns a value that will be displayed in the message box. When you call a Sub procedure you can use the Call statement, like this: Call MyProc(argument) Or, you can omit the Call statement, like this: MyProc argument

VBScript built-in functions

A brief description of the math and other built-in functions available in VBScript. Atn(number) Returns the arctangent of a number. Cos(number) Returns the cosine of an angle. Fix(number) Returns the integer portion of a number. Join(list[, delimiter]) Returns a string created by joining a number of substrings contained in an array. LBound(arrayname[, dimension]) Returns the smallest available subscript for the indicated dimension of an array. LoadPicture(picturename) Returns a picture object. Available only on 32-bit platforms. Log(number) Returns the natural logarithm of a number. Oct(number) Returns a string representing the octal value of a number. ScriptEngine Returns a string representing the scripting language in use (VBScript, Jscript, VBA). ScriptEngineBuildVersion Returns the build version number of the scripting engine in use. ScriptEngineMajorVersion Returns the major version number of the scripting engine in use. ScriptEngineMinorVersion Returns the minor version number of the scripting engine in use. Sgn(number) Returns an integer indicating the sign of a number. Sin(number) Returns the sine of an angle. Space(number) Returns a string consisting of the specified number of spaces. Returns a zero-based, one-dimensional array containing a specified number of substrings. Tan(number) Returns the tangent of an angle. TypeName(varname) Returns a string that provides Variant subtype information about a variable. VarType(varname) Returns a value indicating the subtype of a variable. Examples Dim weekdays(7) weekdays(0) = "Mon" weekdays(1) = "Tue" weekdays(2) = "Wed" weekdays(3) = "Thu" weekdays(4) = "Fri" weekdays(5) = "Sat" weekdays(6) = "Sun" wscript.echo (Join(weekdays,",") “I think that I've learned to relax, and trust in and hire very talented people, and trust in their abilities a little more” - Mark Romanek Related Loop Statements - Do-Loop, FOR-Next, For Each, While. Function - Write a custom VBScript function.

How-to: A list of useful WScript properties

Properties of the WScript object: WScript.Application This property is read only and returns a reference to the current WScript instance. WScript.BuildVersion This property is read only and returns a Long value which is the build version number of cscript (or wscript). WScript.FullName This property returns the full path to cscript (or wscript). This property is read only. WScript.Interactive [= True|False] The Interactive property returns a Boolean that indicates if cscript (or wscript) was invoked in interactive mode. This property is read/write and can be used to change the mode of the currently executing script at runtime. When this property is False, the interactive commands Echo, MsgBox and InputBox have no effect. WScript[.Name] The Name property is read only and returns the name of the WScript object (usually "Windows Script Host"). This is the default property of the WScript object. WScript.Path This property is read only and returns the full path to the directory containing cscript (or wscript). WScript.ScriptFullName This property is read only and returns the full path to the script currently being executed. WScript.ScriptName This property is read only and returns the filename of the script currently being executed. WScript.StdErr This property returns a TextStream object that outputs text to the Standard Error stream. This property is read only and can only be used when cscript is the host executable. WScript.StdIn The StdIn property returns a TextStream object that reads text from the Standard Input stream. This property is read only and can only be used when cscript is the host executable. WScript.StdOut This property returns a TextStream object that outputs text to the Standard Output stream. This property is read only and can only be used when cscript is the host executable. WScript.Timeout[ = lngTimeout] This property is used to set or get the timeout period (in seconds) for the currently executing script. The script will automatically be terminated after the number of seconds specified by this property, which is of type Long. WScript.Version This property is read only and returns a string that is the version number of the host executable. Examples 'Output the version of Microsoft Windows Script Host. strVer = WScript.Version WScript.Echo strVer 'Output the full path-name of the currently running script. strFull = WScript.ScriptFullName WScript.Echo strFull 'The Application property returns a reference to the current instance of the WScript object. Set objWScript = WScript.Application If WScript = objWScript Then WScript.Echo "This proves they refer to the same thing" End If “To me, movies and music go hand in hand. When I'm writing a script, one of the first things I do is find the music I'm going to play for the opening sequence” ~ Quentin Tarantino Related .CreateObject - Create a WSH automation object. cscript - Run a VBScript .vbs file.

How-to: VBScript Naming Convention

Some recommended prefixes for VBScript variables. DataType ShortPrefix Prefix Example String s str strFirstName DateTime t dtm dtmStart Integer i int intQuantity Double d dbl dblTolerance Single sng sngAverage Long l lng lngDistance Byte byt bytRasterData Boolean b bln blnFound Array a arr arrMyArray Collection c col colMyCollrction Class cls clsMyObject Error err errOrderNum Object o obj objCurrent This is designed to generate variable names which are both short and descriptive. For example without a naming convention you might have variables called PartNumber, PartDescription, and Delivery_Date following this naming convention they would become intPart, strPart, dtmDelivery. Some names are reseverd words, any name which exactly matches a datatype (String, Long, Int) e.g. string = "Testing" will produce an error: Illegal Assignment or compilation error. Using a naming convention prefix makes such naming collisions much less likely. Try to avoid variable names which duplicate the prefix naming, i.e for a File System Object objFS makes more sense than objFSO - we already know that it's an object from the obj prefix. The prefix can also be abbreviated to a single digit e.g. sFirstName, iQuantity this assumes you don't have any need to distinguish String from Single or DateTime from Double. All VBScript variables are variants meaning that a variable can contain a string or an integer number or a date etc, This makes it easy to write VBScript code but it can also be easy to lose track of which variable should contain which type of data. “If I had to live my life again, I'd make the same mistakes, only sooner” ~ Tallulah Bankhead.

How-to: Get the current date [getdate.vbs]

Return the current Year/Month/Day and Time formatted as a string. ' Syntax: ' CSCRIPT /nologo getdate.vbs Dim dt dt=now 'output format: yyyymmddHHnn wscript.echo ((year(dt)*100 + month(dt))*100 + day(dt))*10000 + hour(dt)*100 + minute(dt) Example C:\demo> CSCRIPT /nologo getdate.vbs C:\demo> 201307081735 “If future generations are to remember us with gratitude rather than contempt, we must leave them more than the miracles of technology. We must leave them a glimpse of the world as it was in the beginning, not just after we got through with it” ~ President Lyndon B. Johnson Related GetDate.cmd - Get todays date Windows batch file. datetime.vbs - Get Date, Time and Daylight savings. Easter.vbs - Function to calculate the date of Easter.

How-to: Get the current Date and Time [Datetime.vbs]

' Syntax: ' CSCRIPT datetime.vbs 'Returns: Year, Month, Day, Hour, Minute, Seconds, Offset from GMT, Daylight Savings=True/False strComputer = "." ' Date and time Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objItem in colItems dtmLocalTime = objItem.LocalDateTime dtmMonth = Mid(dtmLocalTime, 5, 2) dtmDay = Mid(dtmLocalTime, 7, 2) dtmYear = Left(dtmLocalTime, 4) dtmHour = Mid(dtmLocalTime, 9, 2) dtmMinutes = Mid(dtmLocalTime, 11, 2) dtmSeconds = Mid(dtmLocalTime, 13, 2) Next ' Daylight savings Set Win32Computer = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") For Each objItem In Win32Computer oGMT = (objItem.CurrentTimeZone / 60) DaySave = objItem.DaylightInEffect Next Wscript.Echo dtmYear & " " & dtmMonth & " " & dtmDay & " " & dtmHour & " " & dtmMinutes & " " & dtmSeconds & " " & oGMT & " " & DaySave Calls: Win32_OperatingSystem Win32_ComputerSystem Alternatives: Win32_LocalTime also gives the time . “If I had to live my life again, I'd make the same mistakes, only sooner” ~ Tallulah Bankhead. Related GetDate.vbs - Return the current Year/month/Day and time. GetDate.cmd - Get todays date Windows batch file. Easter.vbs - Function to calculate the date of Easter.

How-to: Delete files older than N days from a folder. [DelOlder.vbs]

Option Explicit 'On error resume next Dim objFS Dim strDirectoryPath Dim objFolder Dim objFileCollection Dim objFile Dim intDaysOld strDirectoryPath = WScript.Arguments.Item(0) intDaysOld = WScript.Arguments.Item(1) ' Check the number of days is 1 or greater (otherwise it will just delete everything) If (intDaysOld<=0) Then WScript.quit -1 wscript.echo "Delete files more than " & intDaysOld & " days old:" If (IsNull(strDirectoryPath)) Then WScript.quit -1 wscript.echo "Delete from: " & strDirectoryPath wscript.echo "" Set objFS = CreateObject("Scripting.FileSystemObject") set objFolder = objFS.GetFolder(strDirectoryPath) set objFileCollection = objFolder.Files For each objFile in objFileCollection If objFile.DateLastModified < (Date() - intDaysOld) Then Wscript.Echo objFile.Name & " " & objFile.DateLastModified 'objFile.Delete(True) 'To delete for real, remove the ' from the line above End If Next Example cscript delolder.vbs "D:\Demo\log files" 90 “The long run is a misleading guide to current affairs. In the long run, we are all dead” ~ John Maynard Keynes

How-to: Calculate the date of Easter with a function.

The Pascha function below will calculate the date of Easter Sunday. The DemoEaster function calls Pascha() passing a range of years, it will work for years far into the future (millions of years.) [Start Easter.vbs] DemoEaster 1550, 2100 Sub DemoEaster (Y1, Y2) Dim Y, M, D for Y = Y1 to Y2 Pascha Y, M, D Wscript.echo St, Y & "-0" & M & "-" & LdgZ(D) Next End sub Function LdgZ(ByVal N) if (N>=0) and (N<10) then LdgZ = "0" & N else LdgZ = "" & N End function Sub Pascha(iYear, iMonth, iDay) 'Reads Year 'Returns the Month and Day of Easter Sunday. Dim C, G, K, I, J, L G = iYear mod 19 if iYear > 1582 then C = iYear \ 100 K = (C - 17) \ 25 I = C - (C \ 4) - ((C - K) \ 3) + 19 * G + 15 I = I mod 30 I = I - (I \ 28) * (1 - (I \ 28) * (29 \ (I + 1)) * ((21 - G) \ 11)) J = iYear + (iYear \ 4) + I + 2 - C + (C \ 4) J = J mod 7 else I = ((19 * G) + 15) mod 30 J = (iYear + (iYear \ 4) + I) mod 7 end if L = I - J iMonth = 3 + ((L + 40) \ 44) iDay = L + 28 - 31 * (iMonth \ 4) End sub [End Easter.vbs] The Pascha function above gives a Julian date for Easter in years before 1583 otherwise it returns a standard Gregorian date. Source: Newsgroups (May 2003) > Dr J.R. Stockton’s website. The Pascha function is based on the algorithm of Oudin (1940) a recognised algorithm for computing the date of Easter, it can be considered to be in the public domain. This is the Western/Christian definition of Easter, many other methods exist for calculating Easter, "algorithm of Oudin" is a useful Google search to find other Easter algorithms and programming functions. Example cscript easter.vbs “Gather ye rosebuds while ye may, Old Time is still a flying; And that same flower that blooms today, Tomorrow shall be dying” ~ Fredrick O' R. Hayes

How-to: Save and Restore Windows Printer Connections

The three scripts below allow you to save the current users Printer Connections (Print Mappings) to a text file, and later to restore those same Printer Connections by reading the text file. The scripts also save and restore the users choice of default printer. This can be useful if you need to delete the users profile (reprofile) or delete and re-create a user account, or to copy Printer Connections between user accounts. (The text file is stored in %HOMESHARE% rather than %USERPROFILE% because reprofiling will normally delete everything in %USERPROFILE%.) [PrintSave.cmd] cscript PrintQueues.vbs >"%HOMESHARE%\myprinters.txt" [PrintQueues.vbs] Option Explicit On Error Resume Next Dim strDefaultPrinter,objWMIService,colInstalledPrinters, objPrinter ' 1. Get the name of the default Printer ### strDefaultPrinter = DefaultPrinter ' 2. WMI query for current printer connections ### strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") ' 3. Main Loop through printer collection ### For Each objPrinter in colInstalledPrinters If Left(objPrinter.Name, 2) = "\\" Then 'Work only on network printers 'Echo the printer name If strDefaultPrinter = objPrinter.Name Then Wscript.Echo objPrinter.Name & " DEFAULT" Else Wscript.Echo objPrinter.Name End If End If 'End of check for network printers Next 'End of the loop through the printer collection '----------------- ' Functions '----------------- 'Return the default printer Function DefaultPrinter Dim strComputer Dim Result strComputer = "." Result = "" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters If objPrinter.Default = True Then Result = objPrinter.Name End If Next DefaultPrinter = Result End Function [PrintRestore.cmd] @echo off Setlocal :: Restore printer drive mappings from myprinters.txt set _vbs=%temp%\RestorePrinterConnections.vbs Echo On Error resume Next > %_vbs% Echo Dim WshNetwork >> %_vbs% Echo Set WshNetwork = CreateObject("WScript.Network") >> %_vbs% for /f "usebackq tokens=1,2" %%G in ("%HOMESHARE%\myprinters.txt") do call :map %%G %%H cscript %_vbs% Del %_vbs% goto:eof :map Echo %1 Echo WshNetwork.AddWindowsPrinterConnection "%1" >> %_vbs% if /i "%2"=="Default" echo WshNetwork.SetDefaultPrinter "%1" >> %_vbs% Example List the printer connections for the current user: C:\> cscript PrintQueues.vbs Save all network printer connections to the file %HOMESHARE%\myprinters.txt C:\> PrintSave Install a set of printer connections by reading the file %HOMESHARE%\myprinters.txt C:\> PrintRestore “Do you know the difference between education and experience? Education is when you read the fine print; experience is what you get when you don’t” ~ Pete Seeger

How-to: Automatically connect to a different Printer Queue [QChange]

This page contains a VBScript that can be used to update a user's printer connections (Print Mappings) In addition to switching to a different Print Queue (or Print Server ) the script will also also preserve the user's current default printer. i.e if their default printer is renamed then the new name will be set as their default. Multiple queues can be moved at once. The changes required are listed in a simple text file, the script will ignore any other print connections not explicitly listed. Execute the script like this: cscript qchange.vbs changes.txt //NoLogo [changes.txt] \\Server\Printer1;\\NewServer\NewPrinter1 \\Server\Printer2;\\NewServer\NewPrinter2 \\Server\Printer3;\\NewServer\NewPrinter2 [end] [Qchange.vbs] On Error Resume Next Const VERBOSE = "N" 'Display progress (Y or N) Const Title = "Print Connection Migrator" Const ForReading = 1 Dim strDefaultPrinter Dim InstalledPrinters 'Array of printer names Dim Textfile 'File with print Q names Dim OldPrintQueues() 'Dynamic array to store old print queue names, from the text file Dim NewPrintQueues() 'Dynamic array to store new print queue names, from the text file Dim fso 'File System Object Dim objTextFile 'Text file object Dim strNextLine 'Line of the text file Dim i Dim WshNetwork Set WshNetwork = CreateObject("WScript.Network") ' 1. - Get the command line args ### SET Parameters = Wscript.arguments 'If no command line arguments provided, quit If Parameters.Count = 0 Then WScript.Quit(1) Else Textfile = Parameters.item(0) End If If Textfile = "" or Not Right(TextFile,4) = ".txt" or Not FileExist(Textfile) Then Error=MsgBox("No valid input file provided. Stopping the script now.",vbokonly, Title) WScript.Quit(1) End If If VERBOSE = "Y" Then Wscript.Echo "Reading input file" ' 2. Read the text file and import it in a Array ### Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile (TextFile, ForReading) i=-1 While not objTextFile.AtEndOfStream i = i+1 Redim Preserve OldPrintQueues(i) ReDim Preserve NewPrintQueues(i) strLine = objTextFile.Readline 'Do not import the comment lines If Left(strLine,2) = "\\" Then OldPrintQueues(i) = Left(strLine,InStr(strline,";")-1) If VERBOSE = "Y" Then Wscript.Echo " old Q is: " & OldPrintQueues(i) NewPrintQueues(i) = Mid(strline,InStr(strline,";")+1,Len(strline)) If VERBOSE = "Y" Then Wscript.Echo " new Q is: " & NewPrintQueues(i) End If Wend objTextFile.Close ' 3. Store the name of the default Printer ### strDefaultPrinter = DefaultPrinter If VERBOSE = "Y" Then Wscript.Echo " Default is: " & strDefaultPrinter ' 4. WMI query for current printer connections ### strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") ' 5. Main Loop through printer collection ### For Each objPrinter in colInstalledPrinters If VERBOSE = "Y" Then Wscript.Echo " Current connection: " & objPrinter.Name If Left(objPrinter.Name, 2) = "\\" Then 'Work only On network printers 'Search the corresponding printer and create it i = 0 'set the indice at the beginning of the array (prepare to loop) Do Until i > UBound(OldPrintQueues) If UCase(objPrinter.Name) = UCase(OldPrintQueues(i)) Then 'Create the connection to the new printer If VERBOSE = "Y" Then Wscript.Echo " New connection: " & NewPrintQueues(i) WshNetwork.AddWindowsPrinterConnection NewPrintQueues(i) If UCase(strDefaultPrinter) = UCase(objPrinter.Name) Then 'This is the default printer 'Set the default Printer WshNetwork.SetDefaultPrinter NewPrintQueues(i) End If 'Delete the printer connection WshNetwork.RemovePrinterConnection objPrinter.Name If VERBOSE = "Y" Then Wscript.Echo " Removing : " & objPrinter.Name End If i = i + 1 Loop End If 'End of check for network printers Next 'End of the loop through the printers of this user Set WshNetwork = Nothing '----------------- ' Functions '----------------- 'Return the default printer Function DefaultPrinter Dim strComputer Dim Result strComputer = "." Result = "" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters If objPrinter.Default = True Then Result = objPrinter.Name End If Next DefaultPrinter = Result End Function '----------------- 'Does File Exist (Boolean) Function FileExist (FileFullPath) Dim Fso Set Fso = CreateObject("Scripting.FileSystemObject") If (Fso.FileExists(FileFullPath)) Then FileExist = True Else FileExist = False End If End Function ' Based on a script by: Sebastien Pittet (pittet.org) ' Creative Commons Attribution-ShareAlike 2.5 ' https://creativecommons.org/licenses/by-sa/2.5/ ' Simon Sheppard Sept 2005 ' https://ss64.com/vb/syntax-qchange.html [end] List all the print queues available on a server with: C:\> net view \\MyServer If you generate the list of printers via code - check the line endings are <CR> <LF> “The large print giveth, the small print taketh away” ~ Tom Waits Related: Syntax - Printing PrintSave - Save and Restore Windows Printer Connections. PRINTBRM - Print queue Backup/Recovery. PRNCNFG - Configure or rename a printer. PRNMNGR - Add, delete, list printers and printer connections. RUNDLL32 - Add/remove print connections SHARE - List or edit a file share or print share. WMIC PRINTER - Set printing options through WMI.

How-to: VBScript to Pin or UnPin items to the Start Menu (Windows 10)

Executable files on the local machine may be Pinned to the Start Menu and/or Taskbar. In the latest versions of Windows 10, this can no longer be done by invoking the pin/unpin verb in VBScript. An alternative is to use the TechnoSys utility PinToTaskbar which can pin executables, but not batch files or metro apps to the Start Menu or Task bar for the current user. The utility works by impersonating the Explorer.exe process, but it also temporarily changes the prompt color to green.
“It is not the place for a program to decide unilaterally, 'I am so cool. I am your favorite icon. I just know it'” ~ The Old New Thing

How-to: Search AD

Search Active Directory for either Users, Computers or Groups. The LDAP query string below can be modified to return different information. Alternative search query strings can be written using the Active Directory Users and Computers (ADUC) GUI. 'SearchAD.vbs On Error Resume Next ' Connect to the LDAP server's root object Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strTarget = "LDAP://" & strDNSDomain wscript.Echo "Starting search from " & strTarget ' Connect to Ad Provider Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCmd = CreateObject("ADODB.Command") Set objCmd.ActiveConnection = objConnection ' Show only computers objCmd.CommandText = "SELECT Name, ADsPath FROM '" & strTarget & "' WHERE objectCategory = 'computer'" ' or show only users 'objCmd.CommandText = "SELECT Name, ADsPath FROM '" & strTarget & "' WHERE objectCategory = 'user'" ' or show only groups 'objCmd.CommandText = "SELECT Name, ADsPath FROM '" & strTarget & "' WHERE objectCategory = 'group'" Const ADS_SCOPE_SUBTREE = 2 objCmd.Properties("Page Size") = 100 objCmd.Properties("Timeout") = 30 objCmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCmd.Properties("Cache Results") = False Set objRecordSet = objCmd.Execute ' Iterate through the results objRecordSet.MoveFirst Do Until objRecordSet.EOF sComputerName = objRecordSet.Fields("Name") wscript.Echo sComputerName objRecordSet.MoveNext Loop Examples cscript SearchAD.vbs cscript SearchAD.vbs >output.txt “Face the facts of being what you are, for that is what changes what you are” ~ Soren Kierkegaard Related: ComputerInfo.vbs - List properties of a Computer (as shown in ADUC). userinfo.vbs - List properties of a User (as shown in ADUC). CMD: DSQUERY - Search for an active directory object. Move-Object - Move an AD object (User, Group, computer etc) to a different OU Equivalent PowerShell: Get-adComputer - Get-adUser - Get-adGroup

How-to: Move an AD object to a new Organisational Unit.

This script can be used to move an AD object (User, Group, computer etc) to a different OU within Active Directory. Option Explicit ' Move-object.vbs ObjectToMove TargetOU ObjectType ' ' Move an AD object into a specific OU ' Search AD (from the root) to find the current location of the object. On Error Resume Next Dim strObject,strTargetOU,objTargetOU,objRootDSE,strDNSDomain,strTarget,objConnection,objCmd,objRecordSet Dim Object,strParent,objParentOU,strObjectName,strObjectDN,strObjectOU strObject = Wscript.Arguments(0) strTargetOU = Wscript.Arguments(1) strObjectType = Wscript.Arguments(2) wscript.Echo "Move the Object " & strObject 'wscript.Echo & "into the OU: " & strTargetOU Set objTargetOU = GetObject("LDAP://" & strTargetOU) ' Connect to the LDAP server's root object Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strTarget = "LDAP://" & strDNSDomain ' Connect to AD Provider Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" ' Search command Set objCmd = CreateObject("ADODB.Command") Set objCmd.ActiveConnection = objConnection ' Query to match Object name objCmd.CommandText = "SELECT Name, ADsPath,distinguishedName FROM '" & strTarget & "' WHERE objectCategory = strObjectType AND name='" & strObject & "'" ' Run the Search command Const ADS_SCOPE_SUBTREE = 2 objCmd.Properties("Page Size") = 100 objCmd.Properties("Timeout") = 30 objCmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCmd.Properties("Cache Results") = False Set objRecordSet = objCmd.Execute ' Iterate through the results objRecordSet.MoveFirst Do Until objRecordSet.EOF strObjectName = objRecordSet.Fields("Name") wscript.Echo "Object Name: " & strObjectName strObjectDN = objRecordSet.Fields("distinguishedName") wscript.Echo "Object DN: " & strObjectDN objRecordSet.MoveNext Loop ' Having the current OU we can bind directly to the Object that will be moved. Set Object = GetObject("LDAP://" & strObjectDN) wscript.Echo Object.ADsPath ' Optionally you may want to display the parent OU. strParent = Object.Parent 'wscript.Echo "Parent: " & strParent Set objParentOU = GetObject(strParent) strObjectOU = objParentOU.distinguishedName 'wscript.Echo "ParentOU: " & strObjectOU ' Move the Object On Error Resume Next wscript.Echo "Move the Object [" & strObject & "] to " & strTargetOU objTargetOU.MoveHere Object.ADsPath, vbNullString if err.number <> 0 then wscript.Echo "Error - failed." else wscript.Echo "Complete." end if On Error Goto 0 The valid AD Object types are: User, Contact, Group, Shared Folder, Printer, Computer, Domain Controllers, OU Example cscript Move-object.vbs "johndoe" "LDAP://OU=Users,DC=ss64,DC=com" "User" “The majority of men meet with failure because of their lack of persistence in creating new plans to take the place of those which fail” ~ Napoleon Hill Related: SearchAD - Search AD for Users, Computers or groups.

How-to: List Computers

List all the computers in a given domain. ' ListComputers.vbs On Error Resume Next Set objDomain = GetObject("WinNT://SS64Domain") WScript.echo "Domain : " + objDomain.name For each objDomainItem in objDomain if objDomainItem.Class = "Computer" then WScript.echo objDomainItem.Name end if Next Examples cscript listcomputers.vbs “Microsoft was founded with a vision of a computer on every desk, and in every home. We've never wavered from that vision” ~ Bill Gates Related: SearchAD - Search Active Directory for Users, Computers or groups. ComputerInfo - List Computer properties (as shown in ADUC). Equivalent PowerShell: Get-adComputer - Get one or more AD computers.

How-to: Retrieve Computer Information

List Computer properties as displayed in ADUC 'compinfo.vbs ' Usage: ' cscript //Nologo compinfo.vbs ' List Computer properties as displayed in ADUC On Error Resume Next Dim objSysInfo, objComp Set objSysInfo = CreateObject("ADSystemInfo") ' Current computer Set objComp = GetObject("LDAP://" & objSysInfo.ComputerName) ' or a specific computer: ' Set objComp = GetObject("LDAP://CN=pc005,OU=Computers,DC=ss64,DC=com") WScript.Echo "--- Computer Properties ---" WScript.Echo "Name: " & objComp.name WScript.Echo "cn: " & objComp.cn WScript.Echo "DNSHostName: " & objComp.dNSHostName WScript.Echo "OperatingSystem: " & objComp.operatingSystem WScript.Echo "ServicePack: " & objComp.operatingSystemServicePack WScript.Echo "SAMAccountName: " & objComp.sAMAccountName WScript.Echo "Location: " & objComp.location WScript.Echo "UserAccountControl: " & objComp.userAccountControl WScript.Echo "PrimaryGroupID: " & objComp.primaryGroupID WScript.Echo "WhenCreated: " & objComp.whenCreated WScript.Echo "WhenChanged: " & objComp.whenChanged WScript.Echo "DistinguishedName: " & objComp.distinguishedName “Success is falling nine times and getting up ten” ~ Jon Bon Jovi Related: userinfo.vbs - List properties of a User (as shown in ADUC). Active Directory / LDAP User Attributes. ListComputers.vbs - VBScript to list all computers. SearchAD - Search AD for either Users, Computers or groups. Equivalent PowerShell: Get-adComputer

How-to: List all User accounts from Active Directory

List all the user accounts in a specific domain. 'ListUsers.vbs On Error Resume Next Set objDomain = GetObject("WinNT://SS64Domain") WScript.echo "Domain : " + objDomain.name For each objDomainItem in objDomain if objDomainItem.Class = "User" then WScript.echo objDomainItem.Name + " : Full Name: " + objDomainItem.FullName end if Next Example cscript listusers.vbs “An honest tale speeds best, being plainly told” ~ William Shakespeare, Richard III, Act IV, Scene IV Related: SearchAD - Search AD for Users, Computers or Groups. UserInfo - List properties of a User (as shown in ADUC). Equivalent PowerShell: Get-adUser

How-to: List User Information from Active Directory

List User properties as displayed in ADUC 'userinfo.vbs ' Usage: ' cscript //Nologo userinfo.vbs ' List User properties as displayed in ADUC On Error Resume Next Dim objSysInfo, objUser Set objSysInfo = CreateObject("ADSystemInfo") ' Currently logged in User Set objUser = GetObject("LDAP://" & objSysInfo.UserName) ' or specific user: 'Set objUser = GetObject("LDAP://CN=johndoe,OU=Users,DC=ss64,DC=com") WScript.Echo "DN: " & objUser.distinguishedName WScript.Echo "" WScript.Echo "GENERAL" WScript.Echo "First name: " & objUser.givenName 'WScript.Echo "First name: " & objUser.FirstName WScript.Echo "Initials: " & objUser.initials WScript.Echo "Last name: " & objUser.sn 'WScript.Echo "Last name: " & objUser.LastName WScript.Echo "Display name: " & objUser.displayName 'WScript.Echo "Display name: " & objUser.FullName WScript.Echo "Description: " & objUser.description WScript.Echo "Office: " & objUser.physicalDeliveryOfficeName WScript.Echo "Telephone number: " & objUser.telephoneNumber WScript.Echo "Other Telephone numbers: " & objUser.otherTelephone WScript.Echo "Email: " & objUser.mail ' WScript.Echo "Email: " & objUser.EmailAddress WScript.Echo "Web page: " & objUser.wWWHomePage WScript.Echo "Other Web pages: " & objUser.url WScript.Echo "" WScript.Echo "ADDRESS" WScript.Echo "Street: " & objUser.streetAddress WScript.Echo "P.O. Box: " & objUser.postOfficeBox WScript.Echo "City: " & objUser.l WScript.Echo "State/province: " & objUser.st WScript.Echo "Zip/Postal Code: " & objUser.postalCode WScript.Echo "Country/region: " & objUser.countryCode 'WScript.Echo "Country/region: " & objUser.c '(ISO 4217) WScript.Echo "" WScript.Echo "ACCOUNT" WScript.Echo "User logon name: " & objUser.userPrincipalName WScript.Echo "pre-Windows 2000 logon name: " & objUser.sAMAccountName WScript.Echo "AccountDisabled: " & objUser.AccountDisabled ' WScript.Echo "Account Control #: " & objUser.userAccountControl WScript.Echo "Logon Hours: " & objUser.logonHours WScript.Echo "Logon On To (Logon Workstations): " & objUser.userWorkstations ' WScript.Echo "User must change password at next logon: " & objUser.pwdLastSet WScript.Echo "User cannot change password: " & objUser.userAccountControl WScript.Echo "Password never expires: " & objUser.userAccountControl WScript.Echo "Store password using reversible encryption: " & objUser.userAccountControl ' WScript.Echo "Account expires end of (date): " & objUser.accountExpires WScript.Echo "" WScript.Echo "PROFILE" WScript.Echo "Profile path: " & objUser.profilePath ' WScript.Echo "Profile path: " & objUser.Profile WScript.Echo "Logon script: " & objUser.scriptPath WScript.Echo "Home folder, local path: " & objUser.homeDirectory WScript.Echo "Home folder, Connect, Drive: " & objUser.homeDrive WScript.Echo "Home folder, Connect, To:: " & objUser.homeDirectory WScript.Echo "" WScript.Echo "TELEPHONE" WScript.Echo "Home: " & objUser.homePhone WScript.Echo "Other Home phone numbers: " & objUser.otherHomePhone WScript.Echo "Pager: " & objUser.pager WScript.Echo "Other Pager numbers: " & objUser.otherPager WScript.Echo "Mobile: " & objUser.mobile WScript.Echo "Other Mobile numbers: " & objUser.otherMobile WScript.Echo "Fax: " & objUser.facsimileTelephoneNumber WScript.Echo "Other Fax numbers: " & objUser.otherFacsimileTelephoneNumber WScript.Echo "IP phone: " & objUser.ipPhone WScript.Echo "Other IP phone numbers: " & objUser.otherIpPhone WScript.Echo "Notes: " & objUser.info WScript.Echo "" WScript.Echo "ORGANISATION" WScript.Echo "Title: " & objUser.title WScript.Echo "Department: " & objUser.department WScript.Echo "Company: " & objUser.company WScript.Echo "Manager: " & objUser.manager
List of all User Attributes
Attribute Description
accountExpires
aCSPolicyName
adminCount
adminDescription
adminDisplayName
allowedAttributes
allowedAttributesEffective
allowedChildClasses
allowedChildClassesEffective
assistant
attributeCertificateAttribute
audio
badPasswordTime
badPwdCount
bridgeheadServerListBL
businessCategory
businessRoles
c Country Abbreviation
canonicalName
carLicense
cn Name
co Country
codePage
comment
company
controlAccessRights
countryCode
createTimeStamp
dBCSPwd
defaultClassStore
department
departmentNumber
description
desktopProfile
destinationIndicator
directReports
displayName
displayNamePrintable
distinguishedName
division
dSASignature
dSCorePropagationData
DUP-houseIdentifier-SID
DUP-secretary-SID
dynamicLDAPServer
employeeID
employeeNumber
employeeType
extensionName
facsimileTelephoneNumber
flags
fromEntry
frsComputerReferenceBL
fRSMemberReferenceBL
fSMORoleOwner
generationQualifier
givenName
groupMembershipSAM
groupPriority
groupsToIgnore
homeDirectory
homeDrive
homePhone
homePostalAddress
initials
instanceType
internationalISDNNumber
ipPhone
isCriticalSystemObject
isDeleted
isPrivilegeHolder
isRecycled
jpegPhoto
kMServer
l City
labeledURI
lastKnownParent
lastLogoff
lastLogon
lastLogonTimestamp
lmPwdHistory
localeID
lockoutTime
logonCount
logonHours
logonWorkstation
mail EMail Address
managedObjects
manager
masteredBy
maxStorage
memberOf
mhsORAddress
middleName
mobile
modifyTimeStamp
msCOM-PartitionSetLink
msCOM-UserLink
msCOM-UserPartitionSetLink
msDFSR-ComputerReferenceBL
msDFSR-MemberReferenceBL
msDRM-IdentityCertificate
msDS-AllowedToActOnBehalfOfOtherIdentity
msDS-AllowedToDelegateTo
msDS-Approx-Immed-Subordinates
msDS-AssignedAuthNPolicy
msDS-AssignedAuthNPolicySilo
msDS-AuthenticatedAtDC
msDS-AuthenticatedToAccountlist
msDS-AuthNPolicySiloMembersBL
msDS-Cached-Membership
msDS-Cached-Membership-Time-Stamp
msDS-ClaimSharesPossibleValuesWithBL
msDS-CloudAnchor
mS-DS-ConsistencyChildCount
mS-DS-ConsistencyGuid
mS-DS-CreatorSID
msDS-EnabledFeatureBL
msDS-FailedInteractiveLogonCount
msDS-FailedInteractiveLogonCountAtLastSuccessfulLogon
msDS-HABSeniorityIndex
msDS-HostServiceAccountBL
msDS-IsDomainFor
msDS-IsFullReplicaFor
msDS-IsPartialReplicaFor
msDS-IsPrimaryComputerFor
msDS-KeyCredentialLink
msDS-KeyPrincipalBL
msDS-KrbTgtLinkBl
msDS-LastFailedInteractiveLogonTime
msDS-LastKnownRDN
msDS-LastSuccessfulInteractiveLogonTime
msDS-LocalEffectiveDeletionTime
msDS-LocalEffectiveRecycleTime
msDs-masteredBy
msds-memberOfTransitive
msDS-MembersForAzRoleBL
msDS-MembersOfResourcePropertyListBL
msds-memberTransitive
msDS-NCReplCursors
msDS-NCReplInboundNeighbors
msDS-NCReplOutboundNeighbors
msDS-NC-RO-Replica-Locations-BL
msDS-NcType
msDS-NonMembersBL
msDS-ObjectReferenceBL
msDS-ObjectSoa
msDS-OIDToGroupLinkBl
msDS-OperationsForAzRoleBL
msDS-OperationsForAzTaskBL
msDS-parentdistname
msDS-PhoneticCompanyName
msDS-PhoneticDepartment
msDS-PhoneticDisplayName
msDS-PhoneticFirstName
msDS-PhoneticLastName
msDS-preferredDataLocation
msDS-PrimaryComputer
msDS-PrincipalName
msDS-PSOApplied
msDS-ReplAttributeMetaData
msDS-ReplValueMetaData
msDS-ReplValueMetaDataExt
msDS-ResultantPSO
msDS-RevealedDSAs
msDS-RevealedListBL
msDS-SecondaryKrbTgtNumber
msDS-Site-Affinity
msDS-SourceAnchor
msDS-SourceObjectDN
msDS-SupportedEncryptionTypes
msDS-SyncServerUrl
msDS-TasksForAzRoleBL
msDS-TasksForAzTaskBL
msDS-TDOEgressBL
msDS-TDOIngressBL
msDS-User-Account-Control-Computed
msDS-UserPasswordExpiryTimeComputed
msDS-ValueTypeReferenceBL
msExchAcceptedDomainBL
msExchAccountForestBL
msExchAdministrativeUnitBL
msExchArchiveDatabaseBL
msExchAssociatedAcceptedDomainBL
msExchAuthPolicyBL
msExchAuxMailboxParentObjectIdBL
msExchAvailabilityOrgWideAccountBL
msExchAvailabilityPerUserAccountBL
msExchCatchAllRecipientBL
msExchConferenceMailboxBL
msExchControllingZone
msExchDataEncryptionPolicyBL
msExchDelegateListBL
msExchDeviceAccessControlRuleBL
msExchEvictedMemebersBL
msExchHABRootDepartmentBL
msExchHouseIdentifier
msExchHygieneConfigurationMalwareBL
msExchHygieneConfigurationSpamBL
msExchIMAPOWAURLPrefixOverride
msExchIntendedMailboxPlanBL
msExchMailboxMoveSourceArchiveMDBBL
msExchMailboxMoveSourceMDBBL
msExchMailboxMoveSourceUserBL
msExchMailboxMoveStorageMDBBL
msExchMailboxMoveTargetArchiveMDBBL
msExchMailboxMoveTargetMDBBL
msExchMailboxMoveTargetUserBL
msExchMDBAvailabilityGroupConfigurationBL
msExchMobileRemoteDocumentsAllowedServersBL
msExchMobileRemoteDocumentsBlockedServersBL
msExchMobileRemoteDocumentsInternalDomainSuffixListBL
msExchMultiMailboxDatabasesBL
msExchMultiMailboxLocationsBL
msExchOABGeneratingMailboxBL
msExchOrganizationsAddressBookRootsBL
msExchOrganizationsGlobalAddressListsBL
msExchOrganizationsTemplateRootsBL
msExchOriginatingForest
msExchOWAAllowedFileTypesBL
msExchOWAAllowedMimeTypesBL
msExchOWABlockedFileTypesBL
msExchOWABlockedMIMETypesBL
msExchOWAForceSaveFileTypesBL
msExchOWAForceSaveMIMETypesBL
msExchOWARemoteDocumentsAllowedServersBL
msExchOWARemoteDocumentsBlockedServersBL
msExchOWARemoteDocumentsInternalDomainSuffixListBL
msExchOWATranscodingFileTypesBL
msExchOWATranscodingMimeTypesBL
msExchParentPlanBL
msExchQueryBaseDN
msExchRBACPolicyBL
msExchResourceGUID
msExchResourceProperties
msExchRMSComputerAccountsBL
msExchServerAssociationBL
msExchServerSiteBL
msExchSMTPReceiveDefaultAcceptedDomainBL
msExchSupervisionDLBL
msExchSupervisionOneOffBL
msExchSupervisionUserBL
msExchTransportRuleTargetBL
msExchTrustedDomainBL
msExchUGEventSubscriptionBL
msExchUGMemberBL
msExchUserBL
msExchUserCulture
msIIS-FTPDir
msIIS-FTPRoot
mSMQDigests
mSMQDigestsMig
mSMQSignCertificates
mSMQSignCertificatesMig
msNPAllowDialin
msNPCallingStationID
msNPSavedCallingStationID
msOrg-LeadersBL
msPKIAccountCredentials
msPKI-CredentialRoamingTokens
msPKIDPAPIMasterKeys
msPKIRoamingTimeStamp
msRADIUSCallbackNumber
msRADIUS-FramedInterfaceId
msRADIUSFramedIPAddress
msRADIUS-FramedIpv6Prefix
msRADIUS-FramedIpv6Route
msRADIUSFramedRoute
msRADIUS-SavedFramedInterfaceId
msRADIUS-SavedFramedIpv6Prefix
msRADIUS-SavedFramedIpv6Route
msRADIUSServiceType
msRASSavedCallbackNumber
msRASSavedFramedIPAddress
msRASSavedFramedRoute
msRTCSIP-AcpInfo
msRTCSIP-ApplicationOptions
msRTCSIP-ArchivingEnabled
msRTCSIP-DeploymentLocator
msRTCSIP-FederationEnabled
msRTCSIP-GroupingID
msRTCSIP-InternetAccessEnabled
msRTCSIP-Line
msRTCSIP-LineServer
msRTCSIP-OptionFlags
msRTCSIP-OriginatorSid
msRTCSIP-OwnerUrn
msRTCSIP-PrimaryHomeServer
msRTCSIP-PrimaryUserAddress
msRTCSIP-PrivateLine
msRTCSIP-TargetHomeServer
msRTCSIP-TargetUserPolicies
msRTCSIP-TenantId
msRTCSIP-UserEnabled
msRTCSIP-UserExtension
msRTCSIP-UserLocationProfile
msRTCSIP-UserPolicies
msRTCSIP-UserPolicy
msRTCSIP-UserRoutingGroupId
msSFU30Name
msSFU30NisDomain
msSFU30PosixMemberOf
msTSAllowLogon
msTSBrokenConnectionAction
msTSConnectClientDrives
msTSConnectPrinterDrives
msTSDefaultToMainPrinter
msTSExpireDate
msTSExpireDate2
msTSExpireDate3
msTSExpireDate4
msTSHomeDirectory
msTSHomeDrive
msTSInitialProgram
msTSLicenseVersion
msTSLicenseVersion2
msTSLicenseVersion3
msTSLicenseVersion4
msTSLSProperty01
msTSLSProperty02
msTSManagingLS
msTSManagingLS2
msTSManagingLS3
msTSManagingLS4
msTSMaxConnectionTime
msTSMaxDisconnectionTime
msTSMaxIdleTime
msTSPrimaryDesktop
msTSProfilePath
msTSProperty01
msTSProperty02
msTSReconnectionAction
msTSRemoteControl
msTSSecondaryDesktops
msTSWorkDirectory
name
netbootSCPBL
networkAddress
nonSecurityMemberBL
ntPwdHistory
nTSecurityDescriptor
o
objectCategory
objectClass
objectGUID
objectVersion
operatorCount
otherFacsimileTelephoneNumber
otherHomePhone
otherIpPhone
otherLoginWorkstations
otherMailbox EMail Address (Others)
otherMobile
otherPager
otherTelephone
otherWellKnownObjects
ou
ownerBL
pager
partialAttributeDeletionList
partialAttributeSet
personalPager
personalTitle Title (Mr/Mrs/Miss etc)
photo
physicalDeliveryOfficeName Office Location
possibleInferiors
postalAddress
postalCode
postOfficeBox
preferredDeliveryMethod
preferredLanguage
preferredOU
primaryGroupID
primaryInternationalISDNNumber
primaryTelexNumber
profilePath
proxiedObjectName
proxyAddresses
pwdLastSet
queryPolicyBL
registeredAddress
replPropertyMetaData
replUpToDateVector
repsFrom
repsTo
revision
roomNumber
scriptPath
sDRightsEffective
seeAlso
serialNumber
serverReferenceBL
servicePrincipalName
showInAdvancedViewOnly
siteObjectBL
sn
st State/Province
street
streetAddress
structuralObjectClass
subRefs
subSchemaSubEntry
systemFlags
telephoneAssistant
telephoneNumber
teletexTerminalIdentifier
telexNumber
terminalServer
thumbnailLogo
thumbnailPhoto
title Job Title
uid
unicodePwd
url
userAccountControl
userCertificate
userParameters
userPassword
userPKCS12
userPrincipalName
userSharedFolder
userSharedFolderOther
userSMIMECertificate
userWorkstations
uSNChanged
uSNCreated
uSNDSALastObjRemoved
USNIntersite
uSNLastObjRem
uSNSource
wbemPath
wellKnownObjects
whenChanged
whenCreated
wWWHomePage
x121Address
x500uniqueIdentifier
“Nearly all men can stand adversity, but if you want to test a man's character, give him power” ~ Abraham Lincoln Related: ComputerInfo - List Computer properties (as shown in ADUC). Active Directory / LDAP User Attributes. ListUsers - VBScript to List all Users. UserName - List user's simple name when called with a Distinguished Name. SearchAD - Search AD for either Users, Computers or groups. PowerShell: Get-adUser - Get one or more AD users. PowerShell script to retrieve all attributes of an Active Directory User object, including inherited. adschema attributes - docs.microsoft.com

How-to: Update User Information in Active Directory (LDAP query)

Find all the users with a specific Office in Active Directory (physicalDeliveryOfficeName) and update it to something new. This script could also be modified to target different user attributes. 'OfficeRename.vbs ' ' Find all the users with a specific Office in AD and ' update their Office to a new Name. ' Option Explicit Dim objRootDSE, strDNSDomain, adoCommand, adoConnection Dim strBase, strFilter, strAttributes, strQuery, adoRecordset Dim strDN, strFirstName, strLastName, objUser, strSite,strUserName, strOldOffice, StrNewOffice, intOfficeLen strOldOffice = "College House" strNewOffice = "New Grand Central" intOfficeLen = len(strOldOffice) ' Determine DNS domain name. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") ' Use ADO to search Active Directory. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" adoCommand.ActiveConnection = adoConnection ' Search entire domain. strBase = "<LDAP://" & strDNSDomain & ">" ' Filter on all user objects. strFilter = "(&(objectCategory=person)(objectClass=user))" ' Comma delimited list of attribute values to retrieve. strAttributes = "distinguishedName,givenName,sn,physicalDeliveryOfficeName" ' Construct the LDAP query. strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" ' Run the query. adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 100 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False Set adoRecordset = adoCommand.Execute ' Enumerate the resulting recordset. Do Until adoRecordset.EOF ' Retrieve values. strDN = adoRecordset.Fields("distinguishedName").Value strDN = Replace(strDN, "/", "\/") strSite = adoRecordset.Fields("physicalDeliveryOfficeName").Value strFirstName = adoRecordset.Fields("givenName").Value & "" strLastName = adoRecordset.Fields("sn").Value & "" strUserName = adoRecordset.Fields("distinguishedName").Value If (left(strSite,intOfficeLen) = strOldOffice) Then ' Echo User wscript.echo strFirstName & "." & strLastName & " " & strUserName ' Bind to user object. Set objUser = GetObject("LDAP://" & strDN) ' Assign value to physicalDeliveryOfficeName attribute. objUser.physicalDeliveryOfficeName = strNewOffice ' Save change. objUser.SetInfo End If adoRecordset.MoveNext Loop adoRecordset.Close adoConnection.Close ' Clean up. Set objRootDSE = Nothing Set adoCommand = Nothing Set adoConnection = Nothing Set adoRecordset = Nothing “Nearly all men can stand adversity, but if you want to test a man's character, give him power” ~ Abraham Lincoln Related: ListUsers - List all Users. UserInfo - List properties of a User (as shown in ADUC). UserName - List user's simple name when called with a Distinguished Name. SearchAD - Search AD for either Users, Computers or Groups.

How-to: List a users First and Last name from Active Directory

List a users First and Last name when called with a Distinguished Name. 'uname.vbs ' Display First and Last name for a given DN On Error Resume Next Dim objUser, strDN strDN = WScript.Arguments.Item(0) Set objUser = GetObject("LDAP://" & strDN) WScript.Echo "First name: " & objUser.givenName WScript.Echo "Last name: " & objUser.sn WScript.Echo "Display name: " & objUser.displayName Example cscript //Nologo uname.vbs "CN=johndoe,OU=Users,DC=ss64,DC=com" “I was advised by an American agent when I was about 19 to change my surname” ~ Rachel Weisz Related: UserInfo - List User properties (as shown in ADUC).

How-to: Test if a user is a member of an AD group in VBScript [isMember]

Some functions to determine group membership. You can find an excellent, tried and tested VBScript program to enumerate members of a group over at hilltop labs - https://www.rlmueller.net/Programs/EnumGroup2.txt Example List all members of group64 cscript //nologo EnumGroup2.vbs "group64"

IsMember

There are several approaches for checking group membership in VBScript - consider if you need to check Local or Domain groups, and to include or not include nested permissions. There are also some gotchas to consider - when enumerating the members of a group it is possible that nothing will be returned, one member is returned or multiple members returned. Test your code with all these possibilities. Richard mueller has a number of IsMember scripts
Test group membership for a single user. Test group membership (including nested groups) for a single user or computer.
“If I had to live my life again, I'd make the same mistakes, only sooner” ~ Tallulah Bankhead. Related IFMEMBER - Is the current user a member of a group. Equivalent PowerShell: Get-adGroupMember -Recursive - Get the members of an AD group.

How-to: List Local Admininstrators.

List local administrators across a network domain. 'localadmins.vbs ' Usage: ' cscript //Nologo localadmins.vbs ' List local administrators across a network domain Dim oDomain, strComputer,oLocalGroup,Item,IsOnline ' Enumerate all the computers in the domain (OU specified below) Set oDomain = GetObject ("LDAP://cn=Computers,DC=ss64,DC=com") For Each strComputer in oDomain Wscript.Echo strComputer.CN 'Check if the PC is booted and online IsOnline=PcOnline(strComputer.CN) 'If so then list the local Administrators If IsOnline = true Then Set oLocalGroup = GetObject("WinNT://" & strComputer.CN & "/Administrators,group") For Each item In oLocalGroup.Members Wscript.Echo strComputer.CN & " " & item.ADsPath Next End If Next Function PcOnline (strComputer) 'Check if the remote machine is online. Dim objPing,objStatus Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._ ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'") For Each objStatus in objPing If IsNull(objStatus.ReplySize) Then PcOnline=False Wscript.Echo strComputer & " is NOT available" Else PcOnline = True Wscript.Echo strComputer & " is responding to a ping" End If Next Set objPing=Nothing Set objStatus=Nothing End Function “A good reputation is more valuable than money” ~ Publilius Syrus Related: userinfo.vbs - List User properties (as shown in ADUC)

How-to: Run a VBScript file

To run a VBScript from within another VBScript:
Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "cscript c:\batch\demo.vbs"

Run a CMD batch file

To run a CMD batch file from VBScript: Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "c:\batch\test.cmd"

Run a PowerShell script

To run a PowerShell script from VBScript: Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "powershell -file ""c:\batch\demo.ps1"""
Related Hybrid batch/VBScript Run a script from PowerShell Run a script from the CMD shell “Those that set in motion the forces of evil cannot always control them afterwards” ~ Charles W. Chesnutt

How-to: Run a script with elevated permissions

To run a script 'As Admin' (with elevated permissions) using VBscript can be done by running ShellExecute and setting the runas flag. This can be used to run an executable, or to run an entire script (batch file or VBScript) with elevated permissions. Below is a Batch file that will check if it is running elevated, and if not will prompt for elevation by creating and executing a two line VBScript (~ElevateMe.vbs) the VBScript is created on the fly with a couple of Echo statements: @Echo Off Setlocal :: First check if we are running As Admin/Elevated FSUTIL dirty query %SystemDrive% >nul if %errorlevel% EQU 0 goto START ::Create and run a temporary VBScript to elevate this batch file Set _batchFile=%~f0 Set _Args=%* :: double up any quotes Set _batchFile=""%_batchFile:"=%"" Set _Args=%_Args:"=""% Echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\~ElevateMe.vbs" Echo UAC.ShellExecute "cmd", "/c ""%_batchFile% %_Args%""", "", "runas", 1 >> "%temp%\~ElevateMe.vbs" cscript "%temp%\~ElevateMe.vbs" Exit /B :START :: set the current directory to the batch file location cd /d %~dp0 :: Place the code which requires Admin/elevation below Echo We are now running as admin [%1] [%2] pause

Testing for Elevation

Testing if the current session is elevated can be done with the FSUTIL command (via StackOverflow). FSUTIL dirty query %SystemDrive% >nul If %errorLevel% NEQ 0 ( Echo Failure, please rerun this script from an elevated command prompt. Exiting... Ping 127.0.0.1 3>&1 > nul Exit /B 1 ) Echo Success: this script is running elevated.
When a script is run with elevated permissions several aspects of the user environment will change: The current directory, the current TEMP folder and any mapped drives will be disconnected. “It is impossible to genuinely elevate yourself by pushing another person lower” - Guy Finley Related .ShellExecute - Run a script/application in the Windows Shell (elevated). PowerShell: Run with Elevated Permissions elevate - Command-Line UAC Elevation Utility. Elevation blog

On Error

Error handling in VBScript is very basic, there is no option to immediately branch to an error handling routine. VBScript does not support GoTo or labels that would allow a program jump. When error handling is enabled, execution will continue onto the next line. To trap an error you have to explicitly test the err object to see if it holds an error. Syntax On Error resume next - Enable error handling On Error goto 0 - Disable error handling Error properties: err.Number (default) err.Source err.Description Examples In the examples below - replace the 'code goes here' line with your VBScript commands. Example 1) Trap an error On Error Resume Next ' code goes here If Err.Number <> 0 Then 'error handling: WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End If Example 2) Trap an error or success On Error Resume Next ' code goes here If Err.Number = 0 Then WScript.Echo "It worked!" Else WScript.Echo "Error:" WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End If Example 3) Trap an error On Error Resume Next ' code goes here If Err.Number <> 0 Then ShowError("It failed") Sub ShowError(strMessage) WScript.Echo strMessage WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End Sub “Success is falling nine times and getting up ten” ~ Jon Bon Jovi Related: Syntax - error codes InputBox - Prompt for user input. Equivalent in PowerShell: ErrorAction and $errorActionPreference

How-to: VBScript Error Codes

Runtime and Syntax error codes. Decimal (hex) Description 5 (0x800A0005) Invalid procedure call or argument 6 (0x800A0006) Overflow 7 (0x800A0007) Out of memory 9 (0x800A0009) Subscript out of range 10 (0x800A000A) The Array is of fixed length or temporarily locked 11 (0x800A000B) Division by zero 13 (0x800A000D) Type mismatch 14 (0x800A000E) Out of string space (overflow) 17 (0x800A0011) cannot perform the requested operation 28 (0x800A001C) Stack overflow 35 (0x800A0023) Undefined SUB procedure or Function 48 (0x800A0030) Error loading DLL 51 (0x800A0033) Internal error 52 (0x800A0034) bad file name or number 53 (0x800A0035) File not found 54 (0x800A0036) Bad file mode 55 (0x800A0037) File is already open 57 (0x800A0039) Device I/O error 58 (0x800A003A) File already exists 61 (0x800A003D) Disk space is full 62 (0x800A003E) input beyond the end of the file 67 (0x800A0043) Too many files 68 (0x800A0044) Device not available 70 (0x800A0046) Permission denied 71 (0x800A0047) Disk not ready 74 (0x800A004A) Cannot rename with different drive 75 (0x800A004B) Path/ file access error 76 (0x800A004C) Path not found 91 (0x800A005B) Object variable not set 92 (0x800A005C) For loop is not initialized 94 (0x800A005E) Invalid use of Null 322 (0x800A0142) Could not create the required temporary file 424 (0x800A01A8) Could not find target object 429 (0x800A01AD) ActiveX cannot create object 430 (0x800A01AE) Class does not support Automation 432 (0x800A01B0) File name or class name not found during Automation operation 438 (0x800A01B6) Object doesn't support this property or method 440 (0x800A01B8) Automation error 445 (0x800A01BD) Object does not support this action 446 (0x800A01BE) Object does not support the named arguments 447 (0x800A01BF) Object does not support the current locale 448 (0x800A01C0) Named argument not found 449 (0x800A01C1) parameters are not optional 450 (0x800A01C2) Wrong number of parameters or invalid property assignment 451 (0x800A01C3) is not a collection of objects 453 (0x800A01C5) The specified DLL function was not found 455 (0x800A01C7) Code resource lock error 457 (0x800A01C9) This key already associated with an element of this collection 458 (0x800A01CA) Variable uses an Automation type not supported in VBScript 462 (0x800A01CE) The remote server does not exist or is not available 481 (0x800A01E1) Image is invalid. 500 (0x800A01F4) variable not defined 501 (0x800A01F5) illegal assignment 502 (0x800A01F6) The object is not safe for scripting 503 (0x800A01F7) Object not safe for initializing 504 (0x800A01F8) Object can not create a secure environment 505 (0x800A01F9) invalid or unqualified reference 506 (0x800A01FA) Class/Type is not defined 507 (0x800A01FB) Unexpected error 1001 (0x800A03E9) Insufficient memory 1002 (0x800A03EA) syntax error 1003 (0x800A03EB) Missing ":" 1005 (0x800A03ED) Missing '(' 1006 (0x800A03EE) Missing ')' 1007 (0x800A03EF) Missing "]" 1010 (0x800A03F2) Missing Identifier 1011 (0x800A03F3) Missing = 1012 (0x800A03F4) Missing 'If' 1013 (0x800A03F5) Missing 'To' 1014 (0x800A03F6) Missing 'End' 1015 (0x800A03F7) Missing 'Function' 1016 (0x800A03F8) Missing 'Sub' 1017 (0x800A03F9) Missing 'Then' 1018 (0x800A03FA) Missing 'Wend' 1019 (0x800A03FB) Missing 'Loop' 1020 (0x800A03FC) Missing 'Next' 1021 (0x800A03FD) Missing 'Case' 1022 (0x800A03FE) Missing 'Select' 1023 (0x800A03FF) Missing expression 1024 (0x800A0400) Missing statement 1025 (0x800A0401) Missing end of statement 1026 (0x800A0402) Requires an integer constant 1027 (0x800A0403) Missing 'While' or 'Until' 1028 (0x800A0404) Missing 'While, 'Until,' or End of statement 1029 (0x800A0405) Too many locals or arguments 1030 (0x800A0406) Identifier Too long 1031 (0x800A0407) The number of is invalid 1032 (0x800A0408) Invalid character 1033 (0x800A0409) Unterminated string constant 1034 (0x800A040A) Unterminated comment 1035 (0x800A040B) Nested comment 1037 (0x800A040D) Invalid use of 'Me' Keyword 1038 (0x800A040E) 'loop' statement is missing 'do' 1039 (0x800A040F) invalid 'exit' statement 1040 (0x800A0410) invalid 'for' loop control variable 1041 (0x800A0411) Name redefined 1042 (0x800A0412) Must be the first statement line 1043 (0x800A0413) Cannot be assigned to non - Byval argument 1044 (0x800A0414) Cannot use parentheses when calling Sub 1045 (0x800A0415) Requires a literal constant 1046 (0x800A0416) Missing 'In' 1047 (0x800A0417) Missing 'Class' 1048 (0x800A0418) Must be inside a class definition 1049 (0x800A0419) Missing Let, Set or Get in the property declaration 1050 (0x800A041A) Missing 'Property' 1051 (0x800A041B) The Number of parameters must be consistent with the attribute description 1052 (0x800A041C) cannot have more than one default attribute / method in a class 1053 (0x800A041D) Class did not initialize or terminate the process parameters 1054 (0x800A041E) Property Let or Set should have at least one parameter 1055 (0x800A041F) Error at 'Next' 1056 (0x800A0420) 'Default 'can only be in the' Property ',' Function 'or' Sub 'in the designated 1057 (0x800A0421) 'Default' must be 'Public'" 1058 (0x800A0422) Can only specify the Property Get in the 'Default' 5016 (0x800A1398) Requires a regular expression object 5017 (0x800A1399) Regular expression syntax error 5018 (0x800A139A) The number of words error 5019 (0x800A139B) Regular expressions is missing ']' 5020 (0x800A139C) Regular expressions is missing ')' 5021 (0x800A139D) Character set Cross-border 32766 (0x800A7FFE) True 32767 (0x800A7FFF) False 32811 (0x800A802B) Element was not found 32812 The specified date is not available in the current locale's calendar “Unreasonable haste is the direct road to error” ~ Moliere Related: On Error - Error handling. IsNothing - Function to find Null/Empty values.

How-to: Use Hybrid Batch and VBscript

If you need to run both a batch file and a VBScript, the most simple method is to have, two separate files and run one from another, but that does require both the scripts to be in the same folder (or in some known location) A hybrid script is a single script containing both batch commands and VBscript commands, the way this normally works is to use redirection to create a temporary vbscript file. For example to generate a one line VBScript containing wscript.echo "Hello world", you can do Echo wscript.echo "Hello world" > %temp%\~hi.vbs cscript //nologo %temp%\~hi.vbs The variable %temp% will expand to the users temporary files folder. Writing longer hybrid scripts can involve a lot of Echo and redirection commands, one for every line, so there are several techniques which can be used to make this less verbose, using variables to hold the repeated commands/options, or as below using a comment ('VBS) at the end of every VBScript line and then using Findstr to extract the VBScript. The expression %~f0 resolves to the full path of the batch file, so this allows the script to search itself: @Echo off Setlocal Echo This is a Batch file FINDSTR /E "'VBS" "%~f0 >%temp%\~temp.vbs cscript //nologo %temp%\~temp.vbs Del %temp%\~temp.vbs Echo All Done. EXIT Sub Demo 'VBS wscript.echo "Welcome to VBScript" 'VBS End Sub 'VBS demo 'VBS wscript.quit 0 'VBS “I've actually made a prediction that within 30 years a majority of new cars made in the United States will be electric. And I don't mean hybrid, I mean fully electric” ~ Elon Musk Related Hybrid scripts without a temporary file - StackOverflow Run a script from VBScript Run a script from PowerShell Run a script from the CMD shell

How-to: Create a robust Drive Mapping [MapDrive.vbs]

VBScript to Map a Drive letter to a network file share (non-persistent). This script is designed for reliability, and is aimed at large domains supporting many users. It accounts for 'remembered' connections including those to a file share that no longer exists or which is off-line. This is a good approach for machines that are not always connected to the domain e.g. Laptops. For each drive letter there are several possible states, that may have to be dealt with by the script: - Remembered (persistent connection) / Not Remembered - Already Connected / Connected to the wrong network share / Not Connected. Windows will not map a 'remembered' connection to a different server unless you first unmap & unremember the existing connection, this applies even if the old connection path is currently disconnected. This script will remove any existing Drive Map before connecting to the correct file share. ' Map a network drive ' Usage ' cscript MapDrive.vbs drive fileshare //NoLogo ' cscript MapDrive.vbs H: \\MyServer\MyShare //NoLogo ' ' This script will remove any existing drive map to the same drive letter ' including persistent or remembered connections (Q303209) Option Explicit Dim objNetwork, objDrives, objReg, i Dim strLocalDrive, strRemoteShare, strShareConnected, strMessage Dim bolFoundExisting, bolFoundRemembered Const HKCU = &H80000001 ' Check both parameters have been passed If WScript.Arguments.Count < 2 Then wscript.echo "Usage: cscript MapDrive.vbs drive fileshare //NoLogo" WScript.Quit(1) End If strLocalDrive = UCase(Left(WScript.Arguments.Item(0), 2)) strRemoteShare = WScript.Arguments.Item(1) bolFoundExisting = False ' Check parameters passed make sense If Right(strLocalDrive, 1) <> ":" OR Left(strRemoteShare, 2) <> "\\" Then wscript.echo "Usage: cscript MapDrive.vbs drive fileshare //NoLogo" WScript.Quit(1) End If wscript.echo " - Mapping: " + strLocalDrive + " to " + strRemoteShare Set objNetwork = WScript.CreateObject("WScript.Network") ' Loop through the network drive connections and disconnect any that match strLocalDrive Set objDrives = objNetwork.EnumNetworkDrives If objDrives.Count > 0 Then For i = 0 To objDrives.Count-1 Step 2 If objDrives.Item(i) = strLocalDrive Then strShareConnected = objDrives.Item(i+1) objNetwork.RemoveNetworkDrive strLocalDrive, True, True i=objDrives.Count-1 bolFoundExisting = True End If Next End If ' If there's a remembered location (persistent mapping) delete the associated HKCU registry key If bolFoundExisting <> True Then Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") objReg.GetStringValue HKCU, "Network\" & Left(strLocalDrive, 1), "RemotePath", strShareConnected If strShareConnected <> "" Then objReg.DeleteKey HKCU, "Network\" & Left(strLocalDrive, 1) bolFoundRemembered = True End If End If 'Now actually do the drive map (not persistent) Err.Clear On Error Resume Next objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False 'Error traps If Err <> 0 Then Select Case Err.Number Case -2147023694 'Persistent connection so try a second time On Error Goto 0 objNetwork.RemoveNetworkDrive strLocalDrive, True, True objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False WScript.Echo "Second attempt to map drive " & strLocalDrive & " to " & strRemoteShare Case Else On Error GoTo 0 WScript.Echo " - ERROR: Failed to map drive " & strLocalDrive & " to " & strRemoteShare End Select Err.Clear End If Example: cscript MapDrive.vbs H: \\Server64\teams //NoLogo Simon Sheppard, SS64.com, Feb 2005 Credit (for the difficult parts) to Kenneth MacDonald, Edinburgh University Computing Services. You are free to use or modify this script: Creative Commons Attribution 2.5 License. For drive mapping to work, File and Printer sharing must be enabled on the remote (server) computer. For mapping multiple drives at once, theres an alternative version of this script over in the forum, it avoids having to load CSCRIPT.exe more than once. “Success is falling nine times and getting up ten” ~ Jon Bon Jovi Related: MapDrivePersistent - Map a Drive letter to a network file share (persistent). .MapNetworkDrive - Drive Map. NoDrives - Hide mapped drives from Windows Explorer. NET - Manage network resources. WMIC LOGICALDISK - List mapped drives. Equivalent PowerShell command: New-PSDrive / New-SmbMapping - Create a mapped network drive.

How-to: Create a robust and persistent Drive Mapping [MapDrivePersistent.vbs]

VBScript to Map a Drive letter to a network file share (persistent) This script is designed to maximise the speed of login, so if a drive already has the correct persistent connection it will be left alone. This is a good approach for machines that are running a recent version of Windows and which are always connected to the domain. For each drive letter there are several possible states, that may have to be dealt with by the script: - Remembered (persistent connection) / Not Remembered - Already Connected / Connected to the wrong network share / Not Connected. If a drive does have to be re-connected this script will attempt to remove any 'remembered' connections, including those to a file share that no longer exists or which is off-line. Option Explicit Function MapDrivePersistent(strDrive,strPath) ' strDrive = Drive letter - e.g. "x:" ' strPath = Path to server/share - e.g. "\\server\share" ' Returns a boolean (True or False) Dim objNetwork, objDrives, blnFound, objReg, i Dim strLocalDrive, strRemoteShare, strRemembered, strMessage Const HKCU = &H80000001 ' Check syntax of parameters passed If Right(strDrive, 1) <> ":" OR Left(strPath, 2) <> "\\" Then WScript.echo "Usage: MapDrivePersistent.vbs ""X:"" ""\\server\share"" //NoLogo" WScript.Quit(1) End If Err.clear MapDrivePersistent = False Set objNetwork = WScript.CreateObject("WScript.Network") 'Step 1: Get the current drives Set objDrives = objNetwork.EnumNetworkDrives If Err.Number <> 0 Then 'Code here for error logging Err.Clear MapDrivePersistent = False Exit Function End If WScript.echo " Connecting drive letter: " + strDrive + " to " + strPath 'Step 2: Compare drive letters to the one requested blnFound = False For i = 0 To objDrives.Count - 1 Step 2 If UCase(strDrive) = UCase(objDrives.Item(i)) Then blnFound = True 'Drive letter was found. Now see if the network share on it is the same as requested If UCase(strPath) = UCase(objDrives.Item(i+1)) Then 'Correct mapping on the drive MapDrivePersistent = True Else 'Wrong mapping on drive. Disconnect and remap WScript.Echo "--" objNetwork.RemoveNetworkDrive strDrive, True, True 'Disconnect drive If Err.Number <> 0 Then 'Code here for error logging Err.clear MapDrivePersistent = False Exit Function End If ' To completely remove the previous remembered persistent mapping ' we also delete the associated registry key HKCU\Network\Drive\RemotePath ' In theory this should be covered by bUpdateProfile=True in ' the RemoveNetworkDrive section above but that doesn't always work. Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") objReg.GetStringValue HKCU, "Network\" & Left(strDrive, 1), "RemotePath", strRemembered If strRemembered <> "" Then objReg.DeleteKey HKCU, "Network\" & Left(strDrive, 1) End If ' Connect drive On Error Resume Next WScript.Echo "++" objNetwork.MapNetworkDrive strDrive, strPath, True If Err.Number <> 0 Then 'Code here for error logging Err.clear MapDrivePersistent = False Exit Function End If MapDrivePersistent = True End If End If Next'Drive in the list 'If blnFound is still false, the drive letter isn't being used. So let's map it. If Not blnFound Then On Error Resume Next objNetwork.MapNetworkDrive strDrive, strPath, True If Err.Number <> 0 Then 'Code here for error logging Err.clear MapDrivePersistent = False Exit Function End If MapDrivePersistent = True End If WScript.Echo " ____" End Function Example: ' Call the function in VBScript ' this can just be tacked onto the main script above if not MapDrivePersistent("L:","\\Server64\Library") Then Wscript.Echo " ERROR: Drive L: failed to connect!" End If if not MapDrivePersistent("Z:","\\Server64\groups") Then Wscript.Echo " ERROR: Drive Z: failed to connect!" End If Then to run the whole thing from a short batch file, or from the command line: cscript MapDrives.vbs You are free to use or modify this script: Creative Commons Attribution 2.5 License. For drive mapping to work, 'File and Printer sharing' must be enabled on the remote (server) computer. based on a script by Corey Thomas Better Drive Mapping “You may say I'm a dreamer, but I'm not the only one. I hope someday you'll join us. And the world will live as one” ~ John Lennon Related: MapDrive - Map a Drive letter to a network file share (non-persistent). NET USE - Manage network resources. .MapNetworkDrive - Drive Map. Using Group Policy Preferences to Map Drives Based on Group Membership. NoDrives - Hide mapped drives from Windows Explorer. Q4471218 - Mapped drive may fail to reconnect in Windows 10, version 1809 (Red X). Equivalent PowerShell command: New-PSDrive / New-SmbMapping - Create a mapped network drive.

How-to: CleanRoamingProfile.vbs

Roaming profiles can cause slow logon and logoff times. Over time each users roaming profile will increase in size until it becomes so large and/or contains so many files that logon times will become noticably affected [Loading your Personal Settings...] This script will delete selected files from the user profile of the account currently logged on. Typically it would be run as part of a logon script. The script normally runs in a fraction of a second, it displays the elasped time so you can see exactly how long it takes. Rather than clearing out everything, this script deletes files based on their last modified date. By default it is set to delete cookies over 90 days old, 'Recent document' shortcuts over 14 days old and cached Internet Explorer, Flash & Java files over 5 days old. You can of course edit the settings to suit your environment. For compatibility with both new and old versions of Windows the script detects the OS and selects the appropriate User Profile folders. This script will delete files - make a backup before running it on any live system. Option Explicit 'Variables Dim objShell,FSO,dtmStart,dtmEnd Dim strUserProfile,strAppData Dim objFolder,objFile,strOSversion Wscript.echo "Profile cleanup starting" dtmStart = Timer() 'Get the current users Profile and ApplicationData folders Set objShell = CreateObject("WScript.Shell") strUserProfile=objShell.ExpandEnvironmentStrings("%USERPROFILE%") strAppData=objShell.ExpandEnvironmentStrings("%APPDATA%") 'Wscript.echo strAppData 'Set reference to the file system Set FSO = createobject("Scripting.FileSystemObject") 'Get the windows version strOSversion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion") 'Wscript.echo strOSversion 'Call the DeleteOlder subroutine for each folder 'Application temp files DeleteOlder 14, strAppData & "\Microsoft\Office\Recent" 'Days to keep recent MS Office files DeleteOlder 5, strAppData & "\Microsoft\CryptnetUrlCache\Content" 'IE certificate cache DeleteOlder 5, strAppData & "\Microsoft\CryptnetUrlCache\MetaData" 'IE cert info DeleteOlder 5, strAppData & "\Sun\Java\Deployment\cache" 'Days to keep Java cache 'OS specific temp files if Cint(Left(strOSversion,1)) > 5 Then Wscript.echo "Windows Vista/7/2008..." DeleteOlder 90, strAppData & "\Microsoft\Windows\Cookies" 'Days to keep cookies DeleteOlder 14, strAppData & "\Microsoft\Windows\Recent" 'Days to keep recent files Else Wscript.echo "Windows 2000/2003/XP..." DeleteOlder 90, strUserProfile & "\Cookies" 'Days to keep cookies DeleteOlder 14, strUserProfile & "\Recent" 'Days to keep recent files End if 'Print completed message dtmEnd = Timer() Wscript.echo "Profile cleanup complete, elapsed time: " & FormatNumber(dtmEnd-dtmStart,2) & " seconds" 'Subroutines below Sub DeleteOlder(intDays,strPath) ' Delete files from strPath that are more than intDays old If FSO.FolderExists(strPath) = True Then Set objFolder = FSO.GetFolder(strPath) For each objFile in objFolder.files If DateDiff("d", objFile.DateLastModified,Now) > intDays Then 'Wscript.echo "File: " & objFile.Name objFile.Delete(True) End If Next End If End Sub Run this script using cscript like this: C:\> cscript CleanRoamingProfile.vbs //nologo The performance benefits of reducing the profile folder size may not appear until the second time the script is run. For example for a user with 1000 recent document shortcuts the script might parse through 1000 files, keep the most recent 200 and delete the rest. That process will likely be slower than just copying all 1000 files. However the next time the user logs on they will see a faster logon with fewer files needing to be processed. Copying a large number of small files can take a disproportionately long time due to disc cluster sizes and SMB limitations. This is why Temporary Internet Files are excluded from roaming profiles by default. On a typical user profile the script should run to completion in less than a quarter of a second. “Let him that would move the world, first move himself” ~ Socrates Related: ProfileFolders - Location of User profile folders. Q325376 - Enable verbose logon and logoff status messages. Troubleshooting slow logons - Ned Pyle. Explorer - Slow Network Browsing.

How-to: Find and replace a text string in a file [Replace.vbs]

Before running any global find and replace - make a backup. It is very easy to match and replace text you didn't intend! 'usage: cscript replace.vbs Filename "StringToFind" "stringToReplace" Option Explicit Dim fso,strFilename,strSearch,strReplace,objFile,oldContent,newContent strFilename=WScript.Arguments.Item(0) strSearch=WScript.Arguments.Item(1) strReplace=WScript.Arguments.Item(2) 'Does file exist? Set fso=CreateObject("Scripting.FileSystemObject") if fso.FileExists(strFilename)=false then wscript.echo "file not found!" wscript.Quit end if 'Read file set objFile=fso.OpenTextFile(strFilename,1) oldContent=objFile.ReadAll 'Write file newContent=replace(oldContent,strSearch,strReplace,1,-1,0) set objFile=fso.OpenTextFile(strFilename,2) objFile.Write newContent objFile.Close Example cscript //Nologo replace.vbs c:\docs\demo.txt "Madonna" "Lady Gaga" “Substitute “damn” every time you're inclined to write “very;” your editor will delete it and the writing will be just as it should be” ~ Mark Twain Related: replace - Find and replace text in a string. Repl.bat - FInd and Replace text, JScript/Batch script FindRepl.bat - FInd and Replace text, JScript/Batch script.

VBScript Websites and Books

Websites

Microsoft VB Script language reference. Script resources for IT professionals - Sample VBS and PowerShell scripts from Microsoft. isVBScriptDead.com - Overview and reasons to learn VBScript. Guy Thomas - Tutorials vbs CheatSheet - Quick reminder and reference sheet from AddedBytes.com VBScript's Regular Expression Support microsoft.public.scripting.wsh - a once popular newsgroup. The Scripting Guys Forum - a mix of VBScript, Batch and PowerShell. VBSEdit - Sample scripts. VBScript-to-PowerShell Windows Script Host versus MOM Scripts SS64 VBScript Forum

Recommended Books:

[ Full disclosure: I get a finder's fee on stuff you buy from Amazon.com by clicking through this website. That doesn't cost you anything, but the commissions help to keep the site running ] vbscript VBScript (third edition) by Adrian Kingsley-Hughes A comprehensive overview of VBScript technology with sample code at every stage from beginner to advanced user. General syntax, functions, keywords, style, error handling and an expanded reference section. Advanced coverage on Active Directory Service Interfaces (ADSI), remote scripting, database scripting, and more. nutshell VBScript in a Nutshell by Paul Lomax VBScript reference - for each statement, function, operator, and object, the book gives a quick description of the syntax, rules of its proper use and some examples. advanced vbscript Advanced VBScript for Microsoft Windows Administrators by Don Jones Learn advanced VBScript techniques, including Active Directory Service Interfaces (ADSI) Windows Management Instrumentation (WMI) scripting, security scripting, remote scripting, database scripting, and scripting for Group Policy. automating admin Automating Windows Administration by Stein Borge An all round introduction to VBScript, how to script network configuration, hardware, event log, security and system information retrieval. Covers various Windows administration tasks with WMI and ADSI (Active Directory Services Interface). VBS Edit - Programming editor specifically for VBScript VBScript Reference Manual (PDF) from Indusoft.com
“The man who doesn't read good books has no advantage over the man who can't read them” ~ Mark Twain

Abs

Function that returns the absolute value of a number (ignoring positive/negative sign) Syntax Abs (number) The Abs function will always return a positive number. Examples Dim dblDemo dblDemo = Abs (-123.4) 123.4 dblDemo = Abs (45.1) 45.1 “I've nothing much to offer, There's nothing much to take, I'm an absolute beginner” ~ David Bowie Related: Int - Return the integer portion of a number.

.AppActivate

Activate a running command. Syntax objShell.AppActivate strApplicationTitle Key objShell A WScript.Shell object strApplicationTitle The name of the Application to activate The AppActivate method tries to activate an application whose title is the nearest match to strApplicationTitle. Example Activate Notepad (assuming Notepad is already running). Set objShell = CreateObject("WScript.Shell") objShell.AppActivate "notepad" “The odds against there being a bomb on a plane are a million to one, and against two bombs a million times a million to one. Next time you fly, cut the odds and take a bomb” ~ Benny Hill Related: Command, run command - .Run Equivalent Windows CMD command: START - Start a program or command.

The wscript.Application object

Provides access to any Application, opening a folder will open Windows Explorer. Syntax Set objApp = CreateObject("Wscript.Application") Methods .BrowseForFolder(0, strPrompt, Options, strRoot) .Open "\\servername\folder\" Examples Dim objApp Set objApp = WScript.CreateObject("WScript.Application") objApp.open "\\Server64\folder1" “It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne Related: Shell.Application objects/methods.

Array

Add values to an Array variable Syntax Array (el1,el2,el3) Key el1,2,.. Values (Elements) to add to the array At least one element must be supplied Create an array with 4 items: Dim vaVolcanoes vaVolcanoes=Array("Cinder cone","Composite","Shield volcano","Lava dome") Alternatively define 4 individual elements: Dim vaVolcanoes(3) vaVolcanoes(0)="Cinder cone" vaVolcanoes(1)="Composite" vaVolcanoes(2)="Shield volcano" vaVolcanoes(3)="Lava dome" “Listen to many, speak to a few” ~ William Shakespeare Related: Dim - Declare a new variable or array variable. Filter - Produce an array by filtering an existing array. Equivalent in PowerShell: Arrays

WScript.Arguments

Return command-line parameters. Syntax WScript.Arguments WScript.Arguments(n) WScript.Arguments.item(n) n = Return the single argument n counting from 0 To pass named arguments use: WScript.Arguments.named In addition to the argument itself : MyObject.item(I)you can also retrieve a count or length: MyObject.Count MyObject.Length The default property is .item Examples C:> cscript demo.vbs arg1 value2 33 456 "Last Arg" [demo.vbs] ' Store the arguments in a variable: Set objArgs = Wscript.Arguments 'Count the arguments WScript.Echo objArgs.Count ' Display all command-line arguments For Each strArg in objArgs WScript.Echo strArg Next ' Display the first 3 command-line arguments For I = 0 to 2 Wscript.Echo objArgs(I) Next 'Display just the third argument Wscript.Echo objArgs(2) 'Or without the reference WScript.Echo "The third argument is", WScript.Arguments(2) Rule #1: Don't sweat the small stuff. Rule #2: It's all small stuff - Dr Robert S Eliot, University of Nebraska cardiologist Related: HowTo: Arguments - Command Line arguments. .Shortcut.Arguments. Equivalent Windows CMD command: Parameters - Command Line Parameters.

Asc

Function that returns the Ascii code which represents a specific character. Syntax Asc (string) Asc ("A") will return 65 Examples Dim intDemo intDemo = Asc ("A") MsgBox intDemo > 65 intDemo = Asc ("ABC") MsgBox intDemo > 65 “I've nothing much to offer, There's nothing much to take, I'm an absolute beginner” ~ David Bowie Related: Chr - Return the string character for ChrCode (ASCII code). AscB - Instead of returning the character code for the first character, AscB returns the first byte. AscW(String) - Return Unicode code for string.

AscB

Function that returns the byte code which represents a specific character. The AscB function is used with byte data contained in a string. Instead of returning the character code for the first character, AscB returns the first byte. For Western languages 1 byte = 1 character but many Eastern languages use double-byte/Unicode characters. AscW is provided for platforms that use Unicode characters. It returns the Unicode (wide) character code, thereby avoiding the conversion from Unicode to ANSI. Syntax Ascb (string) Ascb ("A") will return 65 Examples Dim intDemo intDemo = AscB ("A") MsgBox intDemo > 65 intDemo = AscB ("ABC") MsgBox intDemo > 65 “I've nothing much to offer, There's nothing much to take, I'm an absolute beginner” ~ David Bowie Related: Asc(String) - Return ASCII code for string AscW(String) - Return Unicode code for string Int - Return the integer portion of a number.

AscW

Function that returns the Unicode (wide) character code that represents a specific Unicode character. Syntax AscW (string) AscW ("A") will return 65 Examples Dim intDemo intDemo = AscW ("A") MsgBox intDemo > 65 “I've nothing much to offer, There's nothing much to take, I'm an absolute beginner” ~ David Bowie Related: Asc - Return ASCII code for string. AscB - Instead of returning the character code for the first character, AscB returns the first byte. Chr - Return the string character for ChrCode (ASCII code).

StdOut.Write

Echo text to the screen (Stdout) Syntax WScript.StdOut.Write("text string to display") WScript.StdOut.Write(strMyTextVariable) Unlike the Wscript.Echo command, Stdout.Write allows you to write multiple separate items to the same line, use .WriteBlankLines(n) to add newlines. Examples Set objStdOut = WScript.StdOut objStdOut.Write "User: " objStdOut.Write "Joe Smith" objStdOut.WriteBlankLines(1) objStdOut.Write "Procurement Dept" Play the default beep: wscript.stdout.write Chr(07) The default beep is now played through the speakers/audio system, however if you select the 'no sounds' scheme in Contol Panel > Sounds > Change system sounds, then the default beep will not play. “A truth that's told with bad intent, Beats all the lies you can invent” - William Blake Related: .Echo Echo, popup - .Popup MsgBox - Display a dialogue box message. Equivalent Windows CMD command: ECHO - Display message on screen. Equivalent PowerShell cmdlet: Write-Host

.BrowseForFolder

Prompt the user to select a folder. Syntax .BrowseForFolder(WINDOW_HANDLE, "Window Title", WINDOW_OPTIONS, StartPath) Key WINDOW_HANDLE This should always be 0 WINDOW_OPTIONS Const BIF_RETURNONLYFSDIRS = &H0001 (The default) Const BIF_DONTGOBELOWDOMAIN = &H0002 Const BIF_STATUSTEXT = &H0004 Const BIF_RETURNFSANCESTORS = &H0008 Const BIF_EDITBOX = &H0010 Const BIF_VALIDATE = &H0020 Const BIF_NONEWFOLDER = &H0200 Const BIF_BROWSEFORCOMPUTER = &H1000 Const BIF_BROWSEFORPRINTER = &H2000 Const BIF_BROWSEINCLUDEFILES = &H4000 ' These can be combined e.g. BIF_EDITBOX + BIF_NONEWFOLDER StartPath A drive/folder path or one of the following numeric constants: DESKTOP = 0 PROGRAMS = 2 DRIVES = 17 NETWORK = 18 NETHOOD = 19 PROGRAMFILES = 38 PROGRAMFILESx86 = 48 WINDOWS = 36 Although you can display files with .BrowseForFolder, the method will only return a folder, hence the name. Example Dim objFolder, objShell Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.BrowseForFolder(0, "Please select the folder.", 1, "") If Not (objFolder Is Nothing) Then wscript.echo "Folder: " & objFolder.title wscript.echo "Full Path: " & objFolder.Self.path End If “You affect the world by what you browse” ~ Tim Berners-Lee Related: .Application - BrowseForFolder/Open. FileSystemObject - Work with Drives, Folders and Files.

CBool

Function that converts an expression into a boolean ( -1 / 0 ). Syntax CBool (expression) The keywords True and False are predefined constants and are interchangeable with the values -1 and 0, respectively. Example Dim boolExStaff boolExStaff = CBool(False) “The aim of science is not to open the door to infinite wisdom but to set a limit to infinite error” ~ Bertolt Brecht ‘Life of Galileo’ Related: Abs - The absolute value of a number (ignore negative sign) CByte - Convert to byte. CCur - Convert to currency (number). CDate - Convert to Date. CDbl - Convert to Double (number). CInt - Convert to Integer (number). CLng - Convert to Long (number).

CByte

Function that converts an expression into a byte number (0 - 255) Syntax CByte (expression) Example Dim btGrade btGrade = CByte(45) “Superstition sets the whole world in flames; philosophy quenches them” ~ Voltaire Related: CBool - Convert to boolean. CCur - Convert to currency (number). CDate - Convert to Date. CDbl - Convert to Double (number). CInt - Convert to Integer (number). CLng - Convert to Long (number). Convert to Base 36

CCur

Function that converts an expression into a currency value. Syntax CCur (expression) CCur cannot handle Null values. Example Dim curSalary curSalary = CCur(45.764321) “Gold is the money of kings; silver is the money of gentlemen; barter is the money of peasants; but debt is the money of slaves” ~ Norm Franz Related: Q51414 - Internal Format of CURRENCY Data Type. CBool - Convert to boolean. CByte - Convert to byte. CDate - Convert to Date. CDbl - Convert to Double (number). CInt - Convert to Integer (number). CLng - Convert to Long (number). Convert to Base 36 Syntax - IsBlank function to detect Empty or NULL or Zero.

CDate

Function that converts an expression into a date value Syntax CDate (expression) The expression must be a valid date. The Date data type accepts either the date or the time, or both. Possible values range from January 1, 100 to December 31, 9999. CDate cannot handle Null values. Example Dim dtmRetirement dtmRetirement = CDate("Aug 6, 2083") “The hours of folly are measured by the clock, but of wisdom no clock can measure” ~ William Blake Related: CBool - Convert to boolean. CInt - Convert to Integer (number). Standard date and time notation - YYYY-MM-DD Syntax - IsBlank function to detect Empty or NULL or Zero.

CDbl

Function that converts an expression into a Double (Number.) Syntax CDbl (expression) The Double data type stores precision floating point numbers from -1.79769313486232E308 to -4.94065645841247E-324 for negative values or 1.79769313486232E308 to 4.94065645841247E-324 for positive values. CDbl cannot handle Null values. Example Dim dblDemo dblDemo = CDbl(12 * 0.000001) “People have a peculiar pleasure in making converts, that is, in causing others to enjoy what they enjoy, thus finding their own likeness represented and reflected back to them” ~ Johann Wolfgang von Goethe Related: CBool - Convert to boolean. CByte - Convert to byte. CCur - Convert to currency (number). CDate - Convert to Date. CInt - Convert to Integer (number). CLng - Convert to Long (number). Convert to Base 36 Syntax - IsBlank function to detect Empty or NULL or Zero.

Chr

Function that returns the character represented by an Ascii code. Syntax Chr (ascii_code) Chr (65) will return A Example Dim strDemo strDemo = Chr (65) > A “You can easily judge the character of a man by how he treats those who can do nothing for him” ~ James D. Miles Related: Asc - Returns the Ascii code of a character.

ChrB

Return the string character for ChrCode (Byte code.) With the rise of Unicode there is now rarely any need to use ChrB(). Syntax ChrB (ChrCode) ChrB (65) will return A The ChrB function is used with byte data contained in a string. Instead of returning a character, which may be one or two bytes, ChrB always returns a single byte. The behavior of the ChrB function depends on the byte ordering of the hardware platform, and the number of bytes used to represent Unicode characters in the system software. The function will produce different results on each supported operating system. Use with caution. The described behavior pertains to the Win32 version. Example Dim strDemo strDemo = ChrB (65) > A “You can easily judge the character of a man by how he treats those who can do nothing for him” ~ James D. Miles Related: Chr - Return the string character for ChrCode (ASCII code). ChrW - Return the string character for ChrCode (Unicode/DBCS).

ChrW

Return the string character for ChrCode (Unicode/DBCS) Syntax ChrW (ChrCode) ChrW (65) will return A ChrW is provided for platforms that use Unicode characters. Its argument is a Unicode (wide) character code, thereby avoiding the conversion from ANSI to Unicode. Example Dim strDemo strDemo = ChrW (65) > A “You can easily judge the character of a man by how he treats those who can do nothing for him” ~ James D. Miles Related: Chr - Return the string character for ChrCode (ASCII code).

CInt

Function that converts an expression into an integer value Syntax CInt (expression) Fractional values will be rounded to create a whole integer number, Tie-breaking: If the fraction is less than or equal to .5, the result will round down. If the fraction is greater than .5, the result will round up. CInt cannot handle Null values. Example Dim intDemo intDemo = CInt(45.76) >45 “A man is like a fraction whose numerator is what he is and whose denominator is what he thinks of himself. The larger the denominator, the smaller the fraction” ~ Leo Tolstoy Related: CBool - Convert to boolean. CByte - Convert to byte. CCur - Convert to currency (number). CDate - Convert to Date. CDbl - Convert to Double (number). CLng - Convert to Long (number). Convert to Base 36 Syntax - IsBlank function to detect Empty or NULL or Zero.

CLng

Function that converts an expression into a Long (Number) value Syntax CLng (expression) Fractional values will be rounded to create a whole integer number, Tie-breaking: If the fraction is less than or equal to .5, the result will round down. If the fraction is greater than .5, the result will round up. CLng cannot handle Null values. Examples Dim lngDemo lngDemo = CLng(35000.50) >35000 “A man is like a fraction whose numerator is what he is and whose denominator is what he thinks of himself. The larger the denominator, the smaller the fraction” ~ Leo Tolstoy Related: CBool - Convert to boolean. CByte - Convert to byte. CCur - Convert to currency (number). CDate - Convert to Date. CDbl - Convert to Double (number). CInt - Convert to Integer (number). Convert to Base 36 Syntax - IsBlank function to detect Empty or NULL or Zero.

CSng

Function that converts an expression into a Single (Number.) Syntax CSng (expression) Single precision values have only 7 significant digits of precision. Floating-point number types should not be used for storing currency values. Single can be used to store values from -3402823E38 to -1.401298E-45 or from 1.401298E-45 to 3.402823E38. Example Dim sngDemo sngDemo = CSng(64.1234) “People have a peculiar pleasure in making converts, that is, in causing others to enjoy what they enjoy, thus finding their own likeness represented and reflected back to them” ~ Johann Wolfgang von Goethe Related: CBool - Convert to boolean. CByte - Convert to byte. CCur - Convert to currency (number). CDate - Convert to Date. CInt - Convert to Integer (number). CLng - Convert to Long (number). Convert to Base 36

CStr

Function that converts an expression into a String. Syntax CStr(expression) Example Dim strDemo strDemo = CStr("8 St James Street") “People have a peculiar pleasure in making converts, that is, in causing others to enjoy what they enjoy, thus finding their own likeness represented and reflected back to them” ~ Johann Wolfgang von Goethe Related: CBool - Convert to boolean. CByte - Convert to byte. CDate - Convert to Date. CInt - Convert to Integer (number). UCase - Uppercase String

CreateObject / wscript.CreateObject

Create a Windows Scripting Host (WSH) automation object / run an external command. Syntax: Set objObject = CreateObject(ServerName.typeName, [Location]) Key: ServerName The name of the application typeName Type or class of object to create Location The name of the server. (creates the object on a remote server via DCOM) Syntax: Set objObject = WScript.CreateObject(strProgID[, strPrefix]) Key: strProgID The programmatic identifier of the object to create. String value. strPrefix String value indicating the function prefix. Create a local object and hook up its event handlers Objects created with the wscript.CreateObject method using the strPrefix argument are connected objects. These are useful when you want to sync an object's events. CreateObject is a wscript method. Examples Run a cmd command from vbs Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.run("%comspec% /c ipconfig /release") Run a cmd batch file from vbs Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.run("%comspec% /c mybatchfile.cmd") Create a WshController object to run scripts on a remote machine: strServer = "machine_name" strScript = "script_name.vbs" Set objWshController = WScript.CreateObject("WshController") Set objRemoteScript = objWshController.CreateScript(strScript, strServer) objRemoteScript.Execute For the above to work, enable DCOM , then enable WshRemote in the registry: HKLM\Software\Microsoft\Windows Script Host String value: Remote Set Remote to "1" to enable WshRemote and "0" to disable. Create a WshNetwork object (for mapping to a network share) WshNetwork = WScript.CreateObject("WScript.Network") Echo the script mode. WScript.Echo (WScript.Interactive) “..an understanding of Visual Basic would be advantageous although not to a programming level.” ~ Job advert on Monster.com Related: cscript - Run a VBScript .vbs file. .GetObject - Get an Automation object. .ConnectObject - Connect to a COM object. .DisconnectObject - Disconnect from a COM object. .Exec - Run a command. The difference between WScript.CreateObject and CreateObject - Eric Lippert. psExec - Run commands remotely. Equivalent PowerShell: New-Object

.CreateShortcut

Create or edit a Windows Shortcut Syntax objShell.CreateShortcut(strLinkFile) ShortcutObject.property = "Your Value" Key objShell A WScript.Shell object ShortcutObject An existing shortcut object Example Set objShell = WScript.CreateObject("WScript.Shell") Set lnk = objShell.CreateShortcut("C:\MyShortcut.LNK") lnk.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE" lnk.Arguments = "" lnk.Description = "MyProgram" lnk.HotKey = "ALT+CTRL+F" lnk.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2" lnk.WindowStyle = "1" lnk.WorkingDirectory = "C:\Program Files\MyApp" lnk.Save 'Clean up Set lnk = Nothing Similarly in PowerShell: $objShell = New-Object -ComObject WScript.Shell $lnk = $objShell.CreateShortcut("$home\Desktop\DemoShortcut.lnk") $lnk.TargetPath = "C:\demo\application.exe" # add any arguments $lnk.Arguments = "-accepteula" # minimize the window (3=Maximized 7=Minimized 4=Normal) $shortcut.WindowStyle = 7 # Set an icon (can also pull from a DLL 'shell32.dll,8') $lnk.IconLocation = "C:\demo\myicon.ico" # Set a shortcut key $lnk.Hotkey = "ALT+CTRL+R" $lnk.Save() The 'Description' property corresponds to the shortcut "Comment" field, this will be displayed in a tool-tip. HotKey mappings are only usable if the shortcut is on the Desktop or in the Start Menu. Valid hot key-options: "ALT+", "CTRL+", "SHIFT+", and "EXT+". "A" .. "Z", "0" .. "9", "Back", "Tab", "Clear", "Return", "Escape", "Space", and "Prior". Internet Shortcuts Unlike file/folder shortcuts, Internet Explorer Favourite (.URL) files are simple text files which you can create with a couple of ECHO statements: Echo [InternetShortcut] > demo.url Echo URL=https://ss64.com/ >> demo.url “Our life is frittered away by detail... simplify, simplify” - Henry David Thoreau Related: Arguments, display - WshArguments.Item Q263324 - Shortcut command truncates path names if the target does not currently exist. Equivalent Windows CMD command: SHORTCUT - Create a windows shortcut (.LNK file)

CScript.exe / wscript.exe

Run a VBScript / Windows Scripting Host (WSH) script. 'cscript' runs entirely in the command line and is ideal for non-interactive scripts. 'wscript' will popup Windows dialogue boxes for user interaction. Syntax cscript [options...] [ScriptName.vbs] [script_arguments] wscript [options...] [ScriptName.vbs] [script_arguments] Options: ScriptName.vbs : Text file containing VBS commands to be execute. You must include the extension (normally .vbs) //T:nn Timeout script after nn seconds //nologo hide startup logo //Logo or Display logo (default) //I Interactive mode //B or Batch mode //E:engine Use engine for executing script e.g. //E:jscript //H:CScript Change the default vbs script host to CScript.exe //H:WScript Change the default vbs script host to WScript.exe (default) //Job:xxxx Execute a WSF job //S Save current command line options for this user //D Enable Active Debugging //X Execute script in debugger //U Use Unicode for redirected I/O from the console It is important that all options are placed before the .vbs script (and any script arguments) in the command line, otherwise they will be passed as arguments to the script instead of being parsed by CSCRIPT. Like many programs, cscript.exe will by default run as a 64 bit process on a 64 bit Operating System or it will run as a 32 bit process on a 32 bit Operating System. If your VBScript has any dependency on external programs, database connections etc this can make a difference. To run a VBScript as a 32 bit process from a 64 bit OS use C:\Windows\SysWOW64\cscript.exe C:\scripts\demo.vbs

Call one VBScript from another.

This can be done as shown below, although it is often better to put everything in a single script and use Functions to split up the blocks of code. Set objShell = CreateObject("WScript.Shell") objShell.run("cscript C:\scripts\demo.vbs")
The VB Script scripting environment is installed by default on Windows 98 and all later versions of Windows. Examples Run the VB script called myscript.vbs: C:\> cscript //nologo myscript.vbs If the line above is saved as a batch script, double clicking the batch file will run the VBScript file. “Throw a lucky man in the sea, and he will come up with a fish in his mouth” ~ Arab proverb Related .Exec - execute command. .Run - Run an external Command. .ShellExecute - Run an application in the Windows Shell. Quit - Quit a VBScript.

.CurrentDirectory

Retrieve or change the current directory. The CurrentDirectory returns a string that contains the fully-qualified pathname of the current working directory Syntax .CurrentDirectory Example set objShell = WScript.CreateObject ("WScript.Shell") WScript.Echo (objShell.CurrentDirectory) “There are many terrorist states in the world, but the United States is unusual in that it is officially committed to international terrorism, and on a scale that puts it's rivals to shame” ~ Noam Chomsky Related: Equivalent Windows command: CD - Change Directory - move to a specific Folder.

Date

Return the current date. Syntax Date Example dim dtmCreated dtmCreated = Date “Beauty is Nature's coin, must not be hoarded, but must be current, and the good thereof consists in mutual and partaken bliss” ~ John Milton Related: DateAdd - Add a time interval to a date. DateDiff - Return the time difference between two dates. DatePart - Return part of a given date. Now - Return the current date and time. Time - Return the current system time.

DateAdd

Add a time interval to a Date Syntax DateAdd (interval,number,date) Key number The number of intervals to add date The date interval The date/Time interval to add: yyyy Year q Quarter m Month y Day of year d Day w Weekday h Hour n Minute s Second To subtract dates just specify number as a negative, i.e. "m", -6 will subtract 6 months. Example: add 7 days dtmStart="18-Feb-10" WScript.Echo "Start Date" & dtmStart dtmFinish=DateAdd("d",7,dtmStart) WScript.Echo "End Date" & dtmFinish “We waste time looking for the perfect lover, instead of creating the perfect love” ~ Tom Robbins Related: Date - The current system date. DateDiff - Return the time interval between two dates. DatePart - Return a unit of time from a date. DateSerial - Return a Date from a numeric Year, Month and Day. Weekday - Return the day of the week. Q218964 - VBScript Date and Time formats change with logged on user. Equivalent PowerShell: Date.AddDays(-7)

DateDiff

Return the time interval between two dates. Syntax DateDiff (interval,date1,date2[, FirstDayofWeek [, FirstWeekofYear]]) Key date1 The first date to compare date2 The second date to compare FirstDayofWeek A constant defining the first day of the week: vbUseSystem (0), vbSunday (1=default),vbMonday(2), vbTuesday(3), vbWednesday(4), vbThursday(5), vbFriday(6), vbSaturday(7) FirstWeekofYear A constant defining the first week of the year: vbUseSystem(0), vbFirstJan1(1),vbFirstFourDays(2), vbFirstFullWeek(3) interval The date/Time interval to express the result: yyyy Year q Quarter m Month y Day of year d Day w Weekday h Hour n Minute s Second Example dtm1="18-Feb-10" dtm2="19-Aug-10" WScript.Echo "Difference between " & dtm1 & " and " & dtm2 intMonthsDifferent=DateDiff("m", dtm1, dtm2) WScript.Echo intMonthsDifferent “Listen to many, speak to a few” ~ William Shakespeare Related: Date - The current system date. DateAdd - Add a time interval to a Date. DatePart - Return a unit of time from a date. DateSerial - Return a Date from a numeric Year, Month and Day. Weekday - Return the day of the week. Equivalent PowerShell cmdlet: New-TimeSpan

DatePart

Return a specified part of a given date. Syntax DatePart (interval,date [, FirstDayofWeek [, FirstWeekofYear]]) Key date The date to analyse FirstDayofWeek A constant defining the first day of the week: vbUseSystem (0), vbSunday (1=default),vbMonday(2), vbTuesday(3), vbWednesday(4), vbThursday(5), vbFriday(6), vbSaturday(7) FirstWeekofYear A constant defining the first week of the year: vbUseSystem(0), vbFirstJan1(1),vbFirstFourDays(2), vbFirstFullWeek(3) interval The date/Time interval to express in the result: yyyy Year q Quarter m Month y Day of year d Day w Weekday h Hour n Minute s Second Example dtm1="18-Feb-10" WScript.Echo dtm1 intMonthsinDate=DatePart("m", dtm1) WScript.Echo intMonthsinDate To produce a correct ISO weeknumber requires a function: Function ISOWeekNum(dtmDate) ' Returns a WeekNumber from a date Dim NearThurs NearThurs = ((dtmDate+5) \ 7) * 7 - 2 ISOWeekNum = ((NearThurs - DateSerial(Year(NearThurs), 1, 1)) \ 7) + 1 End function ' Example wscript.echo "ISOWeekNumber: " & ISOWeekNum(cdate("2017-12-25")) “Christmas, children, is not a date. It is a state of mind” ~ Mary Ellen Chase Related: Date - The current system date. Day - Return the day component of a date. DateAdd - Add a time interval to a Date. DateDiff - Return the time interval between two dates. DateSerial - Return a Date from a numeric Year, Month and Day. Month - Return the month component of a date. Year - Return the year component of a date. Q200299 - Format or DatePart Functions return wrong Week number for last Monday in year. Standard date and time notation - YYYY-MM-DD Equivalent PowerShell cmdlet: Get-Date

DateSerial

Return a Date from a numeric Year, Month and Day. Syntax DateSerial (Year, Month, Day) Key Year An integer from 100-9999 representing the year. Month An integer from 1-12 representing the month. Day An integer from 1-31 representing the day. These may also be variables or numeric expressions. Example dtmXMAS=DateSerial(2010,12,25) WScript.Echo dtmXMAS “I always play women I would date” ~ Angelina Jolie Related: Date - The current system date. DateDiff - Return the time interval between two dates. DatePart - Return a unit of time from a date. DateSerial - Return a Date from a numeric Year, Month and Day. Standard date and time notation - YYYY-MM-DD Equivalent PowerShell cmdlet: Get-Date -y 2015 -mo 12 -day 31

DateValue

Return a Date from a string expression. Syntax DateValue (StringExpression) Key StringExpression Any expression recognised by IsDate Example dtmDemo=DateValue("28-Feb-10") WScript.Echo dtmDemo “What is freedom of expression? Without the freedom to offend, it ceases to exist” ~ Salman Rushdie Related: Date - The current system date. DateAdd - Add a time interval to a Date. DateDiff - Return the time interval between two dates. DatePart - Return a unit of time from a date. DateSerial - Return a Date from a numeric Year, Month and Day. Standard date and time notation - YYYY-MM-DD Equivalent PowerShell cmdlet: $CastAsDate = [datetime] "2014-12-01"

Day

Returns the day of the month. Syntax Day ( date_value ) Example Dim intMonthDay intMonthDay = Day(#12/31/2012#) “If you are planning for a year, sow rice; if you are planning for a decade, plant trees; if you are planning for a lifetime, educate people” ~ Chinese Proverb Related: Date - The current date. Now - The current system date and time. GetDate.vbs - Return the current Year/month/Day and time. Standard date and time notation - YYYY-MM-DD

Dim

Explicitly declare a new variable or array variable. Syntax Dim Varname[([subscript])] [,Varname[([subscript])] ...] Key Varname Name for the new variable. subscript For an array variable, the maximum number of array elements. This is zero based so 4 will create a variable with 5 elements, and 0 will create an array with 1 element. Dim statements are not required unless the VBScript contains an Option Explicit statement. Unlike many other languages there is no need to specify a data type (integer, string, object etc) All VBScript variables are variants. You can choose a variable name that indicates the data type to be stored e.g. strEmployee, but this is not enforced. Examples Option explicit Dim myString, price myString="Hello world" price=123 Create an Array Variable with 3 elements: Dim strPrintQueues(2) strPrintQueues(0)="HP Deskjet 1200" strPrintQueues(1)="Kyocera first floor" strPrintQueues(2)="Mikes printer" “Listen to many, speak to a few” ~ William Shakespeare Related: Array - Add values to an Array variable. Private VarName - Declare a local variable/array variable. Public VarName - Declare a public variable/array variable. Equivalent PowerShell cmdlet: $MyVariable = SomeValue

Do ... Loop, Do While..., Do Until...

Repeat a block of statements. Syntax Do [While condition] [Statements] [Exit Do] [Statements] Loop or: Do [Until condition] [Statements] [Exit Do] [Statements] Loop or: Do [Statements] [Exit Do] [Statements] Loop [While condition] or: Do [Statements] [Exit Do] [Statements] Loop [Until condition] Key condition A boolean expression that evaluates to True or False Statements VBScript statements to be repeated until condition is True The keyword While will continue the loop as long as condition is True. The keyword Until will continue the loop as long as condition is False. If no condition is specified, the loop will repeat indefinitely or until an Exit Do is encountered. Examples 'Count to 50 Option Explicit Dim counter counter = 0 Do counter = counter + 1 WScript.Echo counter Loop Until counter = 50 WScript.Echo "Final total" & counter ' Count to 100 Option Explicit Dim i i = 0 Do While i < 100 i = i + 1 WScript.Echo i Loop WScript.Echo "Final total" & i “Profit in business comes from repeat customers, customers that boast about your project or service, and that bring friends with them” ~ W. Edwards Deming Related: For...Next - Repeat a block of statements a given number of times. For Each... - Loop through the items in a collection or array. If..Then - Conditionally execute a block of statements. Equivalent PowerShell cmdlet: Do ... While

FileSystemObject

Work with Drives, Folders and Files. Object hierarchy: FileSystemObject FileSystemObject.Drives FileSystemObject.Drives.item FileSystemObject.GetFolder FileSystemObject.GetFile Once a File System Object has been opened you can use Methods and Properties to work with folders and files: FileSystemObject Methods: .BuildPath(strPath, strFileName) .CopyFile(Source, Dest [,Overwrite (True/False)] .CopyFolder(Source, Dest [,Overwrite (True/False)] .CreateFolder(Path) .CreateTextFile(FileName [,Overwrite (True/False) [, Unicode (True/False)]]) .DeleteFile(FileSpec, Force (True/False)) .DeleteFolder(FileSpec, Force (True/False)) .DriveExists(strDrive) (True/False) .FileExists(strFile) (True/False) .FolderExists(strFolder) (True/False) .GetAbsolutePathName(strPath) - Returns a string with the full drive, path, and file names: Drive:\Path\To\File.Ext .GetBaseName(strPath) - Returns a string with the file name, without the extension: File .GetDrive(strDrive) - Returns an object referring to a drive .GetDriveName(strDrive) - Returns a string referring to a drive. Drive: .GetExtensionName(strPath) - Returns a string referring to the extension of the file. Ext .GetFile(strPath) - Returns an object referring to a file. .GetFileName(strPath) - Returns a string referring to a file. File.Ext .GetFolder(strPath) - Returns an object referring to the path. .GetParentFolderName(strPath) - Returns a string referring to the path. \Path\To\ .GetSpecialFolderName(FolderType) FolderType=SystemFolder/TemporaryFolder/WindowsFolder .GetStandardStream(Type [,Unicode (True/False)]) .GetTempName() .MoveFile(Source, Dest) .MoveFolder(Source, Dest) .OpenTextFile(strFile [,IOMode (8=append, 1=Read, 2=Write) [,Create (True/False) [,Format (0=Ascii, -1=Unicode, -2=default)]]]) Drive Properties: AvailableSpace, DriveLetter, DriveType, FileSystem, FreeSpace,IsReady, Path, RootFolder, SerialNumber, ShareName, TotalSize, VolumeName DrivesCollection properties: Count, Item File Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified,Drive, Name, ParentFolder, Path, ShortName, ShortPath, Size, Type File Methods: .copy, .Delete, .Move, .OpenAsTextStream Folder Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified,Drive, Files, IsRootFolder, Name, ParentFolder, Path, ShortName, ShortPath, Size, SubFolders, Type Folder Methods: .copy, .CreateTextFile, .Delete, .Move FoldersCollection properties: Count, Item FoldersCollection Methods: Add Examples Create a text file: Dim objFS, objFile Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.CreateTextFile("C:\work\demo.txt") objFile.WriteLine("some sample text") Open an existing file: Dim objFS, objFile Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.GetFile("C:\Work\Sample.xls") WScript.Echo objFile.DateCreated & objFile.Name Check drive space: Dim objFS, objDrive, objDriveCount Set objFS = CreateObject("Scripting.FileSystemObject") Set objDriveCount = objFS.Drives Set objDrive = objFS.Drives("C") WScript.Echo objDriveCount & " Free Space " & objDrive.AvailableSpace “Is not the whole world a vast house of assignation of which the filing system has been lost?” ~ Quentin Crisp Related: .ReadLine - Accept user text input. Syntax - error codes .MapNetworkDrive - Drive Map. Equivalent PowerShell cmdlet: Get-Item / Get-ChildItem

.MapNetworkDrive

Add a shared network drive mapping. Syntax objNetwork.MapNetworkDrive(strLocalDrive, strRemoteShare, [persistent], [strUser], [strPassword]) Key objNetwork : A WScript.network object strLocalDrive : The drive letter (e.g. L:) strRemoteShare : The UNC path to the remote drive \\MyServer\MyPrinter (String value) persistent : True/False - store the mapping persistently in the users profile default = false strUser : The user name. (Optional) strPassword : The password. (Optional) Example Dim objNetwork, strRemoteShare Set objNetwork = WScript.CreateObject("WScript.Network") strRemoteShare = "\\myserver\users" objNetwork.MapNetworkDrive "H:", strRemoteShare, False To run these commands in PowerShell without calling cscript: $network = New-Object -ComObject WScript.Network $RemoteShare = '\\myserver\users' $network.MapNetworkDrive('H:', $RemoteShare, $false) The example script below takes this a stage further, disconnecting the drive letter first (and coded to cope with persistent and/or disconnected drive shares) DriveMap.vbs - Connect a local drive letter to a remote file share For workgroup machines sharing files via pass-thru authentication with no domain login script, a persistent drive map can be used. Persistent drives will automatically connect to the resource whenever it is available. “The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side” ~ James Baldwin Related: NET, list drive mappings - .EnumNetworkDrives NET, remove drive map - .RemoveNetworkDrive Equivalent Windows CMD command: NET - Manage network resources Equivalent PowerShell command: New-PSDrive - Create a mapped network drive.

WshNetwork.EnumNetworkDrives

Enumerate Network Drives. Syntax WshNetwork.EnumNetworkDrives Example Set WshNetwork = WScript.CreateObject("WScript.Network") Set oDrives = WshNetwork.EnumNetworkDrives For i = 0 to oDrives.Count - 1 Step 2 WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1) Next “When we got into office, the thing that surprised me the most was that things were as bad as we'd been saying they were” ~ John F. Kennedy Related: Map drive - WshNetwork.MapNetworkDrive Remove drive map - WshNetwork.RemoveNetworkDrive Equivalent Windows CMD command: NET - Manage network resources. Equivalent PowerShell cmdlet: Get-PSDrive or [System.IO.DriveInfo]::GetDrives()

.RemoveNetworkDrive

Remove a shared network drive mapping. Syntax objNetwork.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile]) Key objNetwork : A WScript.Network object strName : The mapped drive you want to remove. bForce : Force the removal of the mapped drive (TRUE/FALSE). bUpdateProfile : Remove the mapping from the user's profile (TRUE/FALSE). Example Dim objNetwork Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive "I:", "\\print_server\hp_01","True","jdoe","jdoepassword" objNetwork.RemoveNetworkDrive "I:" “No problem is so formidable that you can't walk away from it” ~ Charles M. Schulz Related: Map drive - .MapNetworkDrive List drive mappings - .EnumNetworkDrives Equivalent Windows CMD command: NET - Manage network resources.

.Echo

Echo a text string to the screen (cscript) or a dialogue box (wscript) Syntax WScript.Echo [Arg1] [,Arg2] [,Arg3] ... Key Arg1, Arg2, Arg3... Optional string values to be displayed. If no arguments are provided a blank line is output. Echo is a wscript method. Examples WScript.Echo "Hello" WScript.Echo Set objNet = WScript.CreateObject("WScript.Network") WScript.Echo "Your Computer Name is " & objNet.ComputerName WScript.Echo "Your Username is " & objNet.UserName An alternative is to use Active Directory: Set objAD = CreateObject("ADSystemInfo") Wscript.Echo "Your Computer Name is " & objAD.ComputerName Wscript.Echo "Your Username is " & objAD.UserName ECHO can be suppressed by setting .Interactive to false e.g. WScript.Echo("Hello") WScript.Interactive = false WScript.Echo("This wont display") WScript.Interactive = true WScript.Echo("This will display") “Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music" ~ Kristian Wilson, Nintendo Inc, 1989 Related: Echo, popup - .Popup Echo text to screen or file - StdOut.Write Equivalent Windows CMD command: ECHO - Display message on screen. Equivalent PowerShell cmdlet: Write-Host

StdOut.Write

Echo text to the screen (Stdout) Syntax WScript.StdOut.Write("text string to display") WScript.StdOut.Write(strMyTextVariable) Unlike the Wscript.Echo command, Stdout.Write allows you to write multiple separate items to the same line, use .WriteBlankLines(n) to add newlines. Examples Set objStdOut = WScript.StdOut objStdOut.Write "User: " objStdOut.Write "Joe Smith" objStdOut.WriteBlankLines(1) objStdOut.Write "Procurement Dept" Play the default beep: wscript.stdout.write Chr(07) The default beep is now played through the speakers/audio system, however if you select the 'no sounds' scheme in Contol Panel > Sounds > Change system sounds, then the default beep will not play. “A truth that's told with bad intent, Beats all the lies you can invent” - William Blake Related: .Echo Echo, popup - .Popup MsgBox - Display a dialogue box message. Equivalent Windows CMD command: ECHO - Display message on screen. Equivalent PowerShell cmdlet: Write-Host

.Popup

Display text in a pop-up message box. Syntax intButton = objShell.Popup(strText,[nSecondsToWait],[strTitle],[nType]) Arguments objShell : A WScript.Shell object strText : String value containing the text you want to appear in the pop-up message box. nSecondsToWait : Maximum length of time to display the pop-up message box (in seconds, Optional, default=infinite) strTitle : Title text string, Optional. nType : Type of buttons and icons (Numeric, Optional) These determine how the message box is used. IntButton : Number of the button (Integer value) This is the value returned when the user OK's the message box. The meaning of nType is determined by combining values from the 2 tables below: Button Types Value Description 0 OK button. 1 OK and Cancel buttons. 2 Abort, Retry, and Ignore buttons. 3 Yes, No, and Cancel buttons. 4 Yes and No buttons. 5 Retry and Cancel buttons. Icon Types Value Description 16 "Stop Mark" icon. 32 "Question Mark" icon. 48 "Exclamation Mark" icon. 64 "Information Mark" icon. Possible values for IntButton the return value: Value Description 1 OK button 2 Cancel button 3 Abort button 4 Retry button 5 Ignore button 6 Yes button 7 No button If the user does not click a button before nSecondsToWait intButton is set to -1. Example Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.Popup "Click me Quick!",, "My Popup Dialogue box" “Come quickly, I am tasting stars!” ~ Dom Perignon, at the moment he discovered champagne Related: Echo - Wscript.Echo Equivalent Windows CMD command: ECHO - Display message on screen.

.Environment

Return a Windows Environment variable. Syntax objShell.Environment([strType]) Key: objShell A WScript.Shell object strType is one of "System" (HKLM), "User" (HKCU), "Volatile" or "Process" Example 'Write to env variables Set objShell = WScript.CreateObject("WScript.Shell") objShell.Environment("USER").Item("MyVar1") = "hello" objShell.Environment("USER").Item("MyVar2") = "world" 'Read Env Variables WScript.Echo objShell.Environment("USER").Item("MyVar1") WScript.Echo objShell.Environment("USER").Item("MyVar2") ' Retrieve the %COMPUTERNAME% system environment variable WScript.Echo objShell.Environment("PROCESS").Item("COMPUTERNAME") ".Item" is actually the default property and can be omitted “It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne Related: Environment variables - Expand - .Delete/Remove Equivalent Windows CMD command: SET - Display, set, or remove environment variables. Equivalent PowerShell cmdlet: Get-Item env:HOMEDRIVE or $env:HOMEDRIVE

.ExpandEnvironmentStrings

Expand a Windows environment variable. Syntax objShell.ExpandEnvironmentStrings(strString) Key objShell A WScript.Shell object strString A PROCESS environment variable (enclosed with "%" characters) Example Set objShell = WScript.CreateObject("WScript.Shell") MsgBox "Prompt is " & objShell.ExpandEnvironmentStrings("%PROMPT%") Note: Variable names are not case-sensitive. ”I would rather train someone and lose them, than not train them and keep them” ~ Zig Ziglar Related: Environment, Read Environment variables Equivalent Windows CMD command: SET - Display, set, or remove environment variables. Equivalent PowerShell cmdlet: Get-Item env:HOMEDRIVE or $env:HOMEDRIVE

.Environment.Remove

Remove a Windows environment variable. Syntax objShell.Environment(strType).Remove(strName) Key objShell A WScript.Shell object strString The environment variable to be removed strType one of "System" (HKLM), "User" (HKCU), "Volatile" or "Process" Example ' Delete the LAST_LOGIN_DATE user environment variable Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.Environment("USER").Remove("LAST_LOGIN_DATE") Note: for anything other than USER variables - the user needs permissions to delete the variable. Environment variables removed with the Remove method are not removed permanently; they are only removed for the current session. I'm sorry Dave... I can't do that ~ HAL 9000 (2001: A Space Odyssey) Related: Environment, read env variables - .Environment Equivalent Windows CMD command: SET - Display, set, or remove environment variables. Equivalent PowerShell cmdlet: Get-Item env:HOMEDRIVE or $env:HOMEDRIVE

Escape

Encode a string of text, "escaping" all characters that are not allowable in web url address strings. Syntax Escape(String) Key String The string of text to convert to an encoded string for use with HTML data transfer. Note some web browsers will display URLs even without properly escaped characters. HTML with unescaped punctuation will fail validation. Example Option Explicit Dim strMessage strMessage = "Sample text with (parentheses) spaces & " & Chr(34) & "quotes" & Chr(34) MsgBox strMessage& vbCR & Escape(strMessage), vbOkOnly+vbInformation, "Demo" “Writing is a form of therapy; sometimes I wonder how all those, who do not write, compose, or paint can manage to escape the madness, the melancholia, the panic fear, which is inherent in a human condition” ~ Graham Greene Related: UnEscape - Return Unicode characters from an escaped ASCII string.

Eval

Evaluate an expression. Syntax Eval (StringExpr) Key StringExpr Any expression that returns a string or a number. The argument stringexpr must be an expression that is stored in a string. If you pass to the Eval function a string that doesn't contain a numeric expression or a function name but only a simple text string, a run-time error occurs. For example, Eval("Smith") results in an error. Examples Eval("1 + 1") returns 2. Eval("1=2") returns False (-1) Eval("5 * 10") returns 50 strResult = Eval("MY_Function()") MsgBox strResult 'displays the result of the function “More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk” ~ Bruce Schneier Related: Syntax - IsBlank function to detect Empty or NULL or Zero.

.Exec

Run an external Command, returning an object. Syntax objShell.Exec (strCommand) Key objShell A WScript.Shell object strCommand The Command to be executed Unlike .Run method, .Exec returns an object which returns additional information about the process started. Example - run the calculator (calc.exe) and display the exit code: Dim objShell,oExec Set objShell = wscript.createobject("wscript.shell") Set oExec = objShell.Exec("calc.exe") WScript.Echo oExec.Status WScript.Echo oExec.ProcessID WScript.Echo oExec.ExitCode The .ExitCode property returns the exit code set by the program (calc.exe) when it exits. .Exec gives the ability to access the standard streams of the executable and allows read/writes to the process's stdout/stderr in real-time while the process executes. while(!Pipe.StdOut.AtEndOfStream) WScript.StdOut.WriteLine(Pipe.StdOut.ReadLine()) ------------ .Terminate Instructs the script engine to end the process. note - this type of process kill does not clean up properly and may cause memory leaks - use only as a last resort! “First rate people hire other first rate people. Second rate people hire third rate people. Third rate people hire fifth rate people” ~ André Weil Related: .Run - Run a command. Execute - Execute one or more statements. .ShellExecute - Run an application in the Windows Shell. Run with elevated permissions - Script to run as Admin. cscript - Run a VB Script .vbs file. Equivalent Windows CMD command: START - Start a specified program or command. Equivalent PowerShell cmdlet: Run/Call - Run a command.

Execute

Execute one or more statements. ExecuteGlobal will execute in the global namespace of the script. Syntax Execute statement ExecuteGlobal statement The required statement argument is a string expression containing one or more statements for execution. To include multiple statements in the statement argument, use colons or embedded line breaks to separate them. There are three things that we may need to do: evaluate expressions, execute statements using local scope and execute statements using global scope. The three methods for these are Eval, which takes an expression and returns its value, Execute, which takes a group of statements and executes them in local scope, and ExecuteGlobal which executes them in global scope.

Execute

The context in which the Execute statement is invoked determines what objects and variables are available to the code being run. In-scope objects and variables are available to code running in an Execute statement. However, it is important to understand that if you execute code that creates a procedure, that procedure does not inherit the scope of the procedure in which it occurred. Like any procedure, the new procedure's scope is global, and it inherits everything in the global scope. Unlike any other procedure, its context is not global scope, so it can only be executed in the context of the procedure where the Execute statement occurred. However, if the same Execute statement is invoked outside of a procedure (i.e., in global scope), not only does it inherit everything in global scope, but it can also be called from anywhere, since its context is global.

ExecuteGlobal

All statements used with ExecuteGlobal are executed in the script's global namespace. This allows code to be added to the program so that any procedure can access it. For example, a VBScript Class statement can be executed at run time and functions can subsequently create new instances of the class. Adding procedures and classes at runtime can be useful, but also introduces the possibility of overwriting existing global variable and functions at runtime. Because this can cause significant programming problems, care should be exercised when using the ExecuteGlobal statement. If you don't need access to a variable or function outside of a procedure, use the Execute statement that will only affect the namespace of the calling function.
Example Run the VBscript examples with cscript.exe nameofscript.vbs //nologo Dim X ' Declare X in global scope. X = "Global" ' Assign global X a value. Sub Proc1 ' Declare procedure. Dim X ' Declare X in local scope. X = "Local" ' Assign local X a value. ' The Execute statement here creates a ' procedure that, when invoked, prints X. ' It print the global X because Proc2 ' inherits everything in global scope. Execute "Sub Proc2: wscript.echo X: End Sub" wscript.echo Eval("X") ' Print local X. Proc2 ' Invoke Proc2 in Proc1's scope. End Sub Proc1 ' Invoke Proc1. 'Proc2 ' This line will cause a vbscript runtime error since ' Proc2 is unavailable outside Proc1. Execute "Sub Proc2: wscript.echo X: End Sub" Proc2 ' This invocation succeeds because Proc2 is now available globally. In practice, particularly with more complex scripts you may want to rewrite the Execute statement on several lines for better readability: SS = "Sub Proc2" & vbCrLf SS = SS & " wscript.echo X" & vbCrLf SS = SS & "End Sub" Execute SS “Anxiety is love's greatest killer. It makes one feel as you might when a drowning man holds unto you. You want to save him, but you know he will strangle you with his panic” ~ Anas Nin Related: .Exec - Run a command. .Run - Run a command.

Exp

Exponential e raised to the nth power. Syntax Exp (number) Key number The power to raise e to. Example Dim dblDemo dblDemo = Exp(3) “The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris Related: Log - Return the natural logarithm of a number.

Exit

Exit a block of Do...Loop, For...Next, Function, or Sub code. Syntax Exit Do Exit For Exit Function Exit Property Exit Sub Exit will immediately exit the procedure or loop in which it appears. Execution will continue with the next statement/command. Exit Do can be used only inside a Do...Loop statement. When used within nested loops, Exit will only exit the current loop. Example Dim indexA, indexB For indexA = 1 to 2 For indexB = 5 to 50 If indexB > 9 Then Exit For End If document.write (indexA & "~" & indexB) Next Next ' Output: 1~5 1~6 1~7 1~8 1~9 2~5 2~6 2~7 2~8 2~9 “Affairs are easier of entrance than of exit; and it is but common prudence to see our way out before we venture in” ~ Aesop Related: Do..Loop - Repeat a block of statements. Wscript.Quit - Exit a VBScript script.

FileSystemObject

Work with Drives, Folders and Files. Object hierarchy: FileSystemObject FileSystemObject.Drives FileSystemObject.Drives.item FileSystemObject.GetFolder FileSystemObject.GetFile Once a File System Object has been opened you can use Methods and Properties to work with folders and files: FileSystemObject Methods: .BuildPath(strPath, strFileName) .CopyFile(Source, Dest [,Overwrite (True/False)] .CopyFolder(Source, Dest [,Overwrite (True/False)] .CreateFolder(Path) .CreateTextFile(FileName [,Overwrite (True/False) [, Unicode (True/False)]]) .DeleteFile(FileSpec, Force (True/False)) .DeleteFolder(FileSpec, Force (True/False)) .DriveExists(strDrive) (True/False) .FileExists(strFile) (True/False) .FolderExists(strFolder) (True/False) .GetAbsolutePathName(strPath) - Returns a string with the full drive, path, and file names: Drive:\Path\To\File.Ext .GetBaseName(strPath) - Returns a string with the file name, without the extension: File .GetDrive(strDrive) - Returns an object referring to a drive .GetDriveName(strDrive) - Returns a string referring to a drive. Drive: .GetExtensionName(strPath) - Returns a string referring to the extension of the file. Ext .GetFile(strPath) - Returns an object referring to a file. .GetFileName(strPath) - Returns a string referring to a file. File.Ext .GetFolder(strPath) - Returns an object referring to the path. .GetParentFolderName(strPath) - Returns a string referring to the path. \Path\To\ .GetSpecialFolderName(FolderType) FolderType=SystemFolder/TemporaryFolder/WindowsFolder .GetStandardStream(Type [,Unicode (True/False)]) .GetTempName() .MoveFile(Source, Dest) .MoveFolder(Source, Dest) .OpenTextFile(strFile [,IOMode (8=append, 1=Read, 2=Write) [,Create (True/False) [,Format (0=Ascii, -1=Unicode, -2=default)]]]) Drive Properties: AvailableSpace, DriveLetter, DriveType, FileSystem, FreeSpace,IsReady, Path, RootFolder, SerialNumber, ShareName, TotalSize, VolumeName DrivesCollection properties: Count, Item File Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified,Drive, Name, ParentFolder, Path, ShortName, ShortPath, Size, Type File Methods: .copy, .Delete, .Move, .OpenAsTextStream Folder Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified,Drive, Files, IsRootFolder, Name, ParentFolder, Path, ShortName, ShortPath, Size, SubFolders, Type Folder Methods: .copy, .CreateTextFile, .Delete, .Move FoldersCollection properties: Count, Item FoldersCollection Methods: Add Examples Create a text file: Dim objFS, objFile Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.CreateTextFile("C:\work\demo.txt") objFile.WriteLine("some sample text") Open an existing file: Dim objFS, objFile Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.GetFile("C:\Work\Sample.xls") WScript.Echo objFile.DateCreated & objFile.Name Check drive space: Dim objFS, objDrive, objDriveCount Set objFS = CreateObject("Scripting.FileSystemObject") Set objDriveCount = objFS.Drives Set objDrive = objFS.Drives("C") WScript.Echo objDriveCount & " Free Space " & objDrive.AvailableSpace “Is not the whole world a vast house of assignation of which the filing system has been lost?” ~ Quentin Crisp Related: .ReadLine - Accept user text input. Syntax - error codes .MapNetworkDrive - Drive Map. Equivalent PowerShell cmdlet: Get-Item / Get-ChildItem

Filter

Produce an array by filtering an existing array. Syntax Filter (SourceArray, FilterString [,Switch [,Compare]]) Key SourceArray An array to be filtered FilterString A string of characters to find in SourceArray Switch If True include items that match FilterString If False include items that don't match FilterString Compare vbBinaryCompare (0), vbTextCompare (1) Example arrDemo=Filter(vaVolcanoes, "Cinder cone") WScript.Echo arrDemo(0) “To be without some of the things you want is an indispensable part of happiness” ~ Bertrand Russell Related: Array - Add values to an Array variable. Equivalent in PowerShell: Hash Tables

Fix

Return the integer portion of a number. Syntax Fix (expression) Key expression The numeric expression whose integer portion will be returned. Negative numbers will be rounded up by Fix(). Example Dim dblDemo dblDemo = Fix(123.64) Will return 123 dblDemo = Fix(-32.45) Will return -32 “If you are planning for a year, sow rice; if you are planning for a decade, plant trees; if you are planning for a lifetime, educate people” ~ Chinese Proverb Related: Int - Return the integer portion of a number (negative numbers round down).

For ... Next Loop

Repeat a block of statements a given number of times. Syntax For counter = initial_value To Max_value [Step stepCounter] [Statements] [Exit For] Next [counter] Key counter A numeric variable initial_value A numeric expression for the starting value Max_value A numeric expression for the maximum value stepCounter A numeric expression for the increment of counter The counter may be either incremented or decremented with a positive or negative value for stepCounter. Example For i = 1 to 20 WScript.Echo i Next “Profit in business comes from repeat customers, customers that boast about your project or service, and that bring friends with them” ~ W. Edwards Deming Related: Do..Loop - Repeat a block of statements. For Each... - Loop through the items in a collection or array. Equivalent PowerShell cmdlet: For

For Each ... Next Loop

Loop through the items in a collection or array. Syntax For Each element In Group [Statements] [Exit For] [Statements] Next [element] Key element A variable used to hold each item in the group Group A collection or a VBScript array Example Set objFSO = CreateObject("Scripting.FileSystemObject") For Each objDrive In objFSO.Drives WScript.Echo objDrive.DriveType Next Set objFolder = objFSO.GetFolder("C:\Work") Set arrFolders = objFolder.SubFolders For Each strFolderName In arrFolders WScript.Echo strFolderName Next “Profit in business comes from repeat customers, customers that boast about your project or service, and that bring friends with them” ~ W. Edwards Deming Related: For...Next - Repeat a block of statements a given number of times. Do..Loop - Repeat a block of statements. Equivalent PowerShell cmdlet: ForEach-Object

FormatCurrency

Format a number with a currency symbol. Syntax FormatCurrency(number [,DecimalPlaces [,IncludeLeadingZero [,UseParenthesis [, GroupDigits]]]] ) Key number The number to format. DecimalPlaces Number of digits to display after the decimal point. IncludeLeadingZero Include a leading zero for numbers <1 and > -1 UseParenthesis Show negative numbers in Parentheis (500) = -500 GroupDigits Group large numbers with commas (or the regional delimiter) Example Set intDemo = 150000.56 WScript.Echo FormatCurrency(intDemo,1) “The best way to destroy the capitalist system is to debauch the currency. By a continuing process of inflation, governments can confiscate, secretly and unobserved, an important part of the wealth of their citizens” ~ John Maynard Keynes Related: FormatNumber - Format a number. FormatPercent - Format a number with a % symbol. FormatDateTime - Format a Date/Time value. Equivalent PowerShell: $myvar = "{0:C}" -f 1500 will display $1500

FormatNumber

Format a number. Syntax FormatNumber(number [,DecimalPlaces [,IncludeLeadingZero [,UseParenthesis [, GroupDigits]]]] ) Key number The number to format. DecimalPlaces Number of digits to display after the decimal point. IncludeLeadingZero Include a leading zero for numbers <1 and > -1 UseParenthesis Show negative numbers in Parentheis (500) = -500 GroupDigits Group large numbers with commas (or the regional delimiter) Example Set intDemo = 150000.56 WScript.Echo FormatNumber(intDemo,1) “A good decision is based on knowledge and not on numbers” ~ Plato Related: FormatCurrency - Format a number with a currency symbol. FormatPercent - Format a number with a % symbol. FormatDateTime - Format a Date/Time value. Equivalent PowerShell: $myVar = "{0:N4}" -f 450 Will display 450.0000 (4 decimal places).

FormatPercent

Format a number with a % symbol. Syntax FormatPercent(number [,DecimalPlaces [,IncludeLeadingZero [,UseParenthesis [, GroupDigits]]]] ) Key number The number to format. DecimalPlaces Number of digits to display after the decimal point. IncludeLeadingZero Include a leading zero for numbers <1 and > -1 UseParenthesis Show negative numbers in Parentheis (500) = -500 GroupDigits Group large numbers with commas (or the regional delimiter) Example Set intDemo = 64.323 WScript.Echo FormatPercent(intDemo,1) “Sex appeal is fifty percent what you've got and fifty percent what people think you've got” ~ Sophia Loren Related: FormatCurrency - Format a number with a currency symbol. FormatNumber - Format a number. FormatDateTime - Format a Date/Time value. Equivalent PowerShell: $myvar = "{0:P1}" -f 0.175 Returns 17.5%

FormatDateTime

Format a Date/Time value. Syntax FormatDateTime(date [,format] ) Key date A date or a string that can be interpreted as a date. The values accepted are dependent on the regional settings of the current user. format The date format: vbGeneralDate (0), vbLongDate (1), vbShortDate (2), vbLongTime (3), vbShortTime (4). Example WScript.Echo FormatDateTime("2012/25/10",vbLongDate) “We all have our time machines. Some take us back, they're called memories. Some take us forward, they're called dreams” ~ Jeremy Irons Related: FormatCurrency - Format a number with a currency symbol. FormatNumber - Format a number. FormatPercent - Format a number with a % symbol. DatePart - Return part of a given date. Standard date and time notation - YYYY-MM-DD Equivalent PowerShell cmdlet: $myvar = (get-date).tolongDatestring() Also: .toshortDatestring .tolongTimestring .toshortTimestring

Function

Define a function procedure. Syntax [Public [Default] | Private ] Function name([arg_List]) [statements] [name=expression] Exit Function [statements] [name=expression] End Function Key Public Extend the scope of this function to all procedures in the project. Public Default Define a method as the default member of a class (Only for public functions defined within a class.) Private Restrict the scope of this function to procedures within the same module. name The name of the function. arg_List Argument variabless passed to the function, comma separated. By default, each local variable=argument (ByRef) To have each local variable=value of the argument prefix the argument with 'ByVal'. statements Program code expression The value to return. In VBScript, functions can be defined before or after the code that calls it. In many other languages (e.g. PowerShell) it is required to define the function before it is called. Placing the definitions first does have the advantage that the finished code can be read from top to bottom without having to jump up and down the page. Examples Function DemoFunc(Arg1, ByRef Arg2) ' Return the two arguments in a single string DemoFunc = "First: " & Arg1 & " second: " & Arg2 End Function 'Now call the function above myDemo = DemoFunc("Hello","World") wscript.echo myDemo “The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris Related: Sub - Start a subprocedure. IsMember.vbs - Function to determine group membership. Equivalent in PowerShell: Functions

GetLocale

Returns the decimal value of the local computers LocaleID. Syntax getLocale() Example Dim myLocale 'Get current location myLocale = GetLocale() “Who looks outside, dreams; who looks inside, awakes” ~ Carl Gustav Jung Related: LCase - Return String in lower case.

Windows Locales

A locale is neither a language nor a country, the same language may be spoken in multiple countries (often with subtle differences) and a single country may speak multiple languages. A locale is therefore an area where a particular language is spoken which may (or may not) align with geographical and/or political boundaries. A locale also includes regional standards for date and time formatting, for example French-Canadians use a different date format to English-Canadians and both of those are different to the date format used in France. In multi-lingual countries it is common for the same user to switch between languages many times a day. In Windows CMD, to retrieve the current locale (short code) use: For /f "tokens=3" %%G in ('Reg query "HKCU\Control Panel\International" /v LocaleName') Do Set _locale=%%G Echo %_Locale% In PowerShell: PS C:\> (Get-WinSystemLocale).Name Locale short codes are based on ISO 639-1 language codes with an ISO 3166 country code appended as needed.
Locale description Short string Hexadecimal value Decimal value Start of Week blank=Monday (ISO default)
Afar aa 0x1000 4096 Sunday
Afar (Djibouti) aa-DJ 0x1000 4096 Saturday
Afar (Eritrea) aa-ER 0x1000 4096
Afar (Ethiopia) aa-ET 0x1000 4096 Sunday
Afrikaans af 0x36 54 Sunday
Afrikaans (Namibia) af-NA 0x1000 4096
Afrikaans (South Africa) af-ZA 0x436 1078 Sunday
Aghem agq 0x1000 4096
Aghem (Cameroon) agq-CM 0x1000 4096
Akan ak 0x1000 4096
Akan (Ghana) ak-GH 0x1000 4096
Albanian sq 0x1C 28
Albanian (Albania) sq-AL 0x41C 1052
Albanian (Kosovo) sq-XK 0x1000 4096
Albanian (Macedonia, FYRO) sq-MK 0x1000 4096
Alsatian gsw 0x84 132
Alsatian (France) gsw-FR 0x484 1156
Alsatian (Liechtenstein) gsw-LI 0x1000 4096
Alsatian (Switzerland) gsw-CH 0x1000 4096
Amharic am 0x5E 94 Sunday
Amharic (Ethiopia) am-ET 0x45E 1118 Sunday
Arabic ar 0x1 1 Sunday
Arabic (Algeria) ar-DZ 0x1401 5121 Saturday
Arabic (Bahrain) ar-BH 0x3C01 15361 Saturday
Arabic (Chad) ar-TD 0x1000 4096
Arabic (Comoros) ar-KM 0x1000 4096
Arabic (Djibouti) ar-DJ 0x1000 4096 Saturday
Arabic (Egypt) ar-EG 0xC01 3073 Saturday
Arabic (Eritrea) ar-ER 0x1000 4096
Arabic (Iraq) ar-IQ 0x801 2049 Saturday
Arabic (Israel) ar-IL 0x1000 4096 Sunday
Arabic (Jordan) ar-JO 0x2C01 11265 Saturday
Arabic (Kuwait) ar-KW 0x3401 13313 Saturday
Arabic (Lebanon) ar-LB 0x3001 12289
Arabic (Libya) ar-LY 0x1001 4097 Saturday
Arabic (Mauritania) ar-MR 0x1000 4096
Arabic (Morocco) ar-MA 0x1801 6145
Arabic (Oman) ar-OM 0x2001 8193 Sunday
Arabic (Palestinian Authority) ar-PS 0x1000 4096
Arabic (Qatar) ar-QA 0x4001 16385 Saturday
Arabic (Saudi Arabia) ar-SA 0x401 1025 Sunday
Arabic (Somalia) ar-SO 0x1000 4096
Arabic (South Sudan) ar-SS 0x1000 4096
Arabic (Sudan) ar-SD 0x1000 4096 Saturday
Arabic (Syria) ar-SY 0x2801 10241 Saturday
Arabic (Tunisia) ar-TN 0x1C01 7169
Arabic (U.A.E.) ar-AE 0x3801 14337 Saturday
Arabic (World) ar-001 0x1000 4096
Arabic (Yemen) ar-YE 0x2401 9217 Saturday
Armenian hy 0x2B 43
Armenian (Armenia) hy-AM 0x42B 1067
Assamese as 0x4D 77
Assamese (India) as-IN 0x44D 1101
Asturian ast 0x1000 4096
Asturian (Spain) ast-ES 0x1000 4096
Asu asa 0x1000 4096
Asu (Tanzania) asa-TZ 0x1000 4096
Azerbaijani az 0x2C 44
Azerbaijani (Cyrillic) az-Cyrl 0x742C 29740
Azerbaijani (Cyrillic, Azerbaijan) az-Cyrl-AZ 0x82C 2092
Azerbaijani (Latin) az-Latn 0x782C 30764
Azerbaijani (Latin, Azerbaijan) az-Latn-AZ 0x42C 1068
Bafia ksf 0x1000 4096
Bafia (Cameroon) ksf-CM 0x1000 4096
Bambara bm 0x1000 4096
Bambara (Latin) bm-Latn 0x1000 4096
Bambara (Latin, Mali) bm-Latn-ML 0x1000 4096
Bangla bn 0x45 69 Sunday
Bangla (Bangladesh) bn-BD 0x845 2117 Sunday
Bangla (India) bn-IN 0x445 1093
Basaa bas 0x1000 4096
Basaa (Cameroon) bas-CM 0x1000 4096
Bashkir ba 0x6D 109
Bashkir (Russia) ba-RU 0x46D 1133
Basque eu 0x2D 45
Basque (Basque) eu-ES 0x42D 1069
Belarusian be 0x23 35
Belarusian (Belarus) be-BY 0x423 1059
Bemba bem 0x1000 4096
Bemba (Zambia) bem-ZM 0x1000 4096
Bena bez 0x1000 4096
Bena (Tanzania) bez-TZ 0x1000 4096
Blin byn 0x1000 4096
Blin (Eritrea) byn-ER 0x1000 4096
Bodo brx 0x1000 4096 Sunday
Bodo (India) brx-IN 0x1000 4096 Sunday
Bosnian bs 0x781A 30746
Bosnian (Cyrillic) bs-Cyrl 0x641A 25626
Bosnian (Cyrillic, Bosnia and Herzegovina) bs-Cyrl-BA 0x201A 8218
Bosnian (Latin) bs-Latn 0x681A 26650
Bosnian (Latin, Bosnia and Herzegovina) bs-Latn-BA 0x141A 5146
Breton br 0x7E 126
Breton (France) br-FR 0x47E 1150
Bulgarian bg 0x2 2
Bulgarian (Bulgaria) bg-BG 0x402 1026
Burmese my 0x55 85 Sunday
Burmese (Myanmar) my-MM 0x455 1109 Sunday
Catalan ca 0x3 3
Catalan (Andorra) ca-AD 0x1000 4096
Catalan (Catalan) ca-ES 0x403 1027
Catalan (France) ca-FR 0x1000 4096
Catalan (Italy) ca-IT 0x1000 4096
Central Atlas Tamazight (Arabic) tzm-Arab 0x1000 4096 Saturday
Central Atlas Tamazight (Arabic, Morocco) tzm-Arab-MA 0x45F 1119 Saturday
Central Atlas Tamazight (Latin, Morocco) tzm-Latn-MA 0x1000 4096 Saturday
Central Atlas Tamazight (Tifinagh, Morocco) tzm-Tfng-MA 0x105F 4191 Saturday
Central Kurdish ku 0x92 146 Sunday
Central Kurdish (Arabic) ku-Arab 0x7C92 31890
Central Kurdish (Iraq) ku-Arab-IQ 0x492 1170 Sunday
Chechen ce 0x1000 4096
Chechen (Russia) ce-RU 0x1000 4096
Cherokee chr 0x5C 92 Sunday
Cherokee (Cherokee) chr-Cher-US 0x45C 1116 Sunday
Cherokee (Cherokee) chr-Cher 0x7C5C 31836 Sunday
Chiga cgg 0x1000 4096
Chiga (Uganda) cgg-UG 0x1000 4096
Chinese zh 0x7804 30724
Chinese (Simplified Han, Hong Kong SAR) zh-Hans-HK 0x1000 4096 Sunday
Chinese (Simplified Han, Macao SAR) zh-Hans-MO 0x1000 4096 Sunday
Chinese (Simplified) zh-Hans 0x4 4
Chinese (Simplified) Legacy zh-Hans 0x4 4
Chinese (Simplified, PRC) zh-CN 0x804 2052
Chinese (Simplified, Singapore) zh-SG 0x1004 4100 Sunday
Chinese (Traditional) zh-Hant 0x7C04 31748 Sunday
Chinese (Traditional) Legacy zh-Hant 0x7C04 31748 Sunday
Chinese (Traditional, Hong Kong S.A.R.) zh-HK 0xC04 3076 Sunday
Chinese (Traditional, Macao S.A.R.) zh-MO 0x1404 5124 Sunday
Chinese (Traditional, Taiwan) zh-TW 0x404 1028 Sunday
Church Slavic cu 0x1000 4096
Church Slavic (Russia) cu-RU 0x1000 4096
Colognian ksh 0x1000 4096
Cornish kw 0x1000 4096
Cornish (United Kingdom) kw-GB 0x1000 4096
Corsican co 0x83 131
Corsican (France) co-FR 0x483 1155
Croatian hr 0x1A 26
Croatian (Croatia) hr-HR 0x41A 1050
Croatian (Latin, Bosnia and Herzegovina) hr-BA 0x101A 4122
Czech cs 0x5 5
Czech (Czech Republic) cs-CZ 0x405 1029
Danish da 0x6 6
Danish (Denmark) da-DK 0x406 1030
Danish (Greenland) da-GL 0x1000 4096
Dari prs 0x8C 140 Saturday
Dari (Afghanistan) prs-AF 0x48C 1164 Saturday
Divehi dv 0x65 101 Sunday
Divehi (Maldives) dv-MV 0x465 1125 Sunday
Duala dua 0x1000 4096
Duala (Cameroon) dua-CM 0x1000 4096
Dutch nl 0x13 19
Dutch (Aruba) nl-AW 0x1000 4096
Dutch (Belgium) nl-BE 0x813 2067
Dutch (Bonaire, Sint Eustatius and Saba) nl-BQ 0x1000 4096
Dutch (Curaao) nl-CW 0x1000 4096
Dutch (Netherlands) nl-NL 0x413 1043
Dutch (Sint Maarten) nl-SX 0x1000 4096
Dutch (Suriname) nl-SR 0x1000 4096
Dzongkha dz 0x1000 4096 Sunday
Dzongkha (Bhutan) dz-BT 0xC51 3153 Sunday
Edo bin 0x66 102 Sunday
Edo (Nigeria) bin-NG 0x466 1126 Sunday
Embu ebu 0x1000 4096 Sunday
Embu (Kenya) ebu-KE 0x1000 4096 Sunday
English en 0x9 9
English (American Samoa) en-AS 0x1000 4096 Sunday
English (Anguilla) en-AI 0x1000 4096
English (Antigua and Barbuda) en-AG 0x1000 4096 Sunday
English (Australia) en-AU 0xC09 3081
English (Austria) en-AT 0x1000 4096
English (Bahamas) en-BS 0x1000 4096 Sunday
English (Barbados) en-BB 0x1000 4096
English (Belgium) en-BE 0x1000 4096
English (Belize) en-BZ 0x2809 10249 Sunday
English (Bermuda) en-BM 0x1000 4096
English (Botswana) en-BW 0x1000 4096 Sunday
English (British Indian Ocean Territory) en-IO 0x1000 4096
English (British Virgin Islands) en-VG 0x1000 4096
English (Burundi) en-BI 0x1000 4096
English (Cameroon) en-CM 0x1000 4096
English (Canada) en-CA 0x1009 4105 Sunday
English (Caribbean) en-029 0x2409 9225
English (Cayman Islands) en-KY 0x1000 4096
English (Christmas Island) en-CX 0x1000 4096
English (Cocos [Keeling] Islands) en-CC 0x1000 4096
English (Cook Islands) en-CK 0x1000 4096
English (Cyprus) en-CY 0x1000 4096
English (Denmark) en-DK 0x1000 4096
English (Dominica) en-DM 0x1000 4096 Sunday
English (Eritrea) en-ER 0x1000 4096
English (Europe) en-150 0x1000 4096
English (Falkland Islands) en-FK 0x1000 4096
English (Fiji) en-FJ 0x1000 4096
English (Finland) en-FI 0x1000 4096
English (Gambia) en-GM 0x1000 4096
English (Germany) en-DE 0x1000 4096
English (Ghana) en-GH 0x1000 4096
English (Gibraltar) en-GI 0x1000 4096
English (Grenada) en-GD 0x1000 4096
English (Guam) en-GU 0x1000 4096 Sunday
English (Guernsey) en-GG 0x1000 4096
English (Guyana) en-GY 0x1000 4096
English (Hong Kong SAR) en-HK 0x3C09 15369 Sunday
English (India) en-IN 0x4009 16393
English (Indonesia) en-ID 0x3809 14345 Sunday
English (Ireland) en-IE 0x1809 6153 Sunday
English (Isle of Man) en-IM 0x1000 4096
English (Israel) en-IL 0x1000 4096
English (Jamaica) en-JM 0x2009 8201 Sunday
English (Jersey) en-JE 0x1000 4096
English (Kenya) en-KE 0x1000 4096 Sunday
English (Kiribati) en-KI 0x1000 4096
English (Lesotho) en-LS 0x1000 4096
English (Liberia) en-LR 0x1000 4096
English (Macao SAR) en-MO 0x1000 4096 Sunday
English (Madagascar) en-MG 0x1000 4096
English (Malawi) en-MW 0x1000 4096
English (Malaysia) en-MY 0x4409 17417 Sunday
English (Malta) en-MT 0x1000 4096 Sunday
English (Marshall Islands) en-MH 0x1000 4096 Sunday
English (Mauritius) en-MU 0x1000 4096
English (Micronesia) en-FM 0x1000 4096
English (Montserrat) en-MS 0x1000 4096
English (Namibia) en-NA 0x1000 4096
English (Nauru) en-NR 0x1000 4096
English (Netherlands) en-NL 0x1000 4096
English (New Zealand) en-NZ 0x1409 5129 Sunday
English (Nigeria) en-NG 0x1000 4096
English (Niue) en-NU 0x1000 4096
English (Norfolk Island) en-NF 0x1000 4096
English (Northern Mariana Islands) en-MP 0x1000 4096
English (Pakistan) en-PK 0x1000 4096 Sunday
English (Palau) en-PW 0x1000 4096
English (Papua New Guinea) en-PG 0x1000 4096
English (Pitcairn Islands) en-PN 0x1000 4096
English (Puerto Rico) en-PR 0x1000 4096 Sunday
English (Philippines) en-PH 0x3409 13321 Sunday
English (Rwanda) en-RW 0x1000 4096
English (Saint Kitts and Nevis) en-KN 0x1000 4096
English (Saint Lucia) en-LC 0x1000 4096
English (Saint Vincent and the Grenadines) en-VC 0x1000 4096
English (Samoa) en-WS 0x1000 4096 Sunday
English (Seychelles) en-SC 0x1000 4096
English (Sierra Leone) en-SL 0x1000 4096
English (Singapore) en-SG 0x4809 18441 Sunday
English (Sint Maarten) en-SX 0x1000 4096
English (Slovenia) en-SI 0x1000 4096
English (Solomon Islands) en-SB 0x1000 4096
English (South Africa) en-ZA 0x1C09 7177 Sunday
English (South Sudan) en-SS 0x1000 4096
English (St Helena, Ascension, Tristan da Cunha) en-SH 0x1000 4096
English (Sudan) en-SD 0x1000 4096 Saturday
English (Swaziland) en-SZ 0x1000 4096
English (Sweden) en-SE 0x1000 4096
English (Switzerland) en-CH 0x1000 4096
English (Tanzania) en-TZ 0x1000 4096
English (Tokelau) en-TK 0x1000 4096
English (Tonga) en-TO 0x1000 4096
English (Trinidad and Tobago) en-TT 0x2C09 11273 Sunday
English (Turks and Caicos Islands) en-TC 0x1000 4096
English (Tuvalu) en-TV 0x1000 4096
English (Uganda) en-UG 0x1000 4096
English (United Kingdom) en-GB 0x809 2057
English (United States) en-US 0x409 1033 Sunday
English (US Minor Outlying Islands) en-UM 0x1000 4096 Sunday
English (US Virgin Islands) en-VI 0x1000 4096 Sunday
English (Vanuatu) en-VU 0x1000 4096
English (World) en-001 0x1000 4096
English (Zambia) en-ZM 0x1000 4096
English (Zimbabwe) en-ZW 0x3009 12297 Sunday
Esperanto eo 0x1000 4096
Esperanto (World) eo-001 0x1000 4096
Estonian et 0x25 37
Estonian (Estonia) et-EE 0x425 1061
Ewe ee 0x1000 4096
Ewe (Ghana) ee-GH 0x1000 4096
Ewe (Togo) ee-TG 0x1000 4096
Ewondo ewo 0x1000 4096
Ewondo (Cameroon) ewo-CM 0x1000 4096
Faroese fo 0x38 56
Faroese (Denmark) fo-DK 0x1000 4096
Faroese (Faroe Islands) fo-FO 0x438 1080
Filipino fil 0x64 100 Sunday
Filipino (Philippines) fil-PH 0x464 1124 Sunday
Finnish fi 0xB 11
Finnish (Finland) fi-FI 0x40B 1035
French fr 0xC 12
French (Algeria) fr-DZ 0x1000 4096 Saturday
French (Belgium) fr-BE 0x80C 2060
French (Benin) fr-BJ 0x1000 4096
French (Burkina Faso) fr-BF 0x1000 4096
French (Burundi) fr-BI 0x1000 4096
French (Cameroon) fr-CM 0x2C0C 11276
French (Canada) fr-CA 0xC0C 3084 Sunday
French (Caribbean) fr-029 0x1C0C 7180
French (Central African Republic) fr-CF 0x1000 4096
French (Chad) fr-TD 0x1000 4096
French (Comoros) fr-KM 0x1000 4096
French (Congo DRC) fr-CD 0x240C 9228
French (Congo) fr-CG 0x1000 4096
French (Cte d’Ivoire) fr-CI 0x300C 12300
French (Djibouti) fr-DJ 0x1000 4096 Saturday
French (Equatorial Guinea) fr-GQ 0x1000 4096
French (France) fr-FR 0x40C 1036
French (French Guiana) fr-GF 0x1000 4096
French (French Polynesia) fr-PF 0x1000 4096
French (Gabon) fr-GA 0x1000 4096
French (Guadeloupe) fr-GP 0x1000 4096
French (Guinea) fr-GN 0x1000 4096
French (Haiti) fr-HT 0x3C0C 15372
French (Luxembourg) fr-LU 0x140C 5132
French (Madagascar) fr-MG 0x1000 4096
French (Mali) fr-ML 0x340C 13324
French (Martinique) fr-MQ 0x1000 4096
French (Mauritania) fr-MR 0x1000 4096
French (Mauritius) fr-MU 0x1000 4096
French (Mayotte) fr-YT 0x1000 4096
French (Monaco) fr-MC 0x180C 6156
French (Morocco) fr-MA 0x380C 14348 Saturday
French (New Caledonia) fr-NC 0x1000 4096
French (Niger) fr-NE 0x1000 4096
French (Reunion) fr-RE 0x200C 8204
French (Rwanda) fr-RW 0x1000 4096
French (Saint Barthélemy) fr-BL 0x1000 4096
French (Saint Martin) fr-MF 0x1000 4096
French (Saint Pierre and Miquelon) fr-PM 0x1000 4096
French (Senegal) fr-SN 0x280C 10252
French (Seychelles) fr-SC 0x1000 4096
French (Switzerland) fr-CH 0x100C 4108
French (Syria) fr-SY 0x1000 4096 Saturday
French (Togo) fr-TG 0x1000 4096
French (Tunisia) fr-TN 0x1000 4096 Sunday
French (Vanuatu) fr-VU 0x1000 4096
French (Wallis and Futuna) fr-WF 0x1000 4096
Frisian fy 0x62 98
Frisian (Netherlands) fy-NL 0x462 1122
Friulian fur 0x1000 4096
Friulian (Italy) fur-IT 0x1000 4096
Fulah ff 0x67 103
Fulah (Cameroon) ff-CM 0x1000 4096
Fulah (Guinea) ff-GN 0x1000 4096
Fulah (Latin) ff-Latn 0x7C67 31847
Fulah (Latin, Senegal) ff-Latn-SN 0x867 2151
Fulah (Mauritania) ff-MR 0x1000 4096
Fulah (Nigeria) ff-NG 0x467 1127 Sunday
Galician gl 0x56 86
Galician (Galician) gl-ES 0x456 1110
Ganda lg 0x1000 4096
Ganda (Uganda) lg-UG 0x1000 4096
Georgian ka 0x37 55
Georgian (Georgia) ka-GE 0x437 1079
German de 0x7 7
German (Austria) de-AT 0xC07 3079
German (Belgium) de-BE 0x1000 4096
German (Germany) de-DE 0x407 1031
German (Italy) de-IT 0x1000 4096
German (Liechtenstein) de-LI 0x1407 5127
German (Luxembourg) de-LU 0x1007 4103
German (Switzerland) de-CH 0x807 2055
Greek el 0x8 8
Greek (Cyprus) el-CY 0x1000 4096
Greek (Greece) el-GR 0x408 1032
Greenlandic kl 0x6F 111
Greenlandic (Greenland) kl-GL 0x46F 1135
Guarani gn 0x74 116 Sunday
Guarani (Paraguay) gn-PY 0x474 1140 Sunday
Gujarati gu 0x47 71
Gujarati (India) gu-IN 0x447 1095
Gusii guz 0x1000 4096 Sunday
Gusii (Kenya) guz-KE 0x1000 4096 Sunday
Hausa ha 0x68 104
Hausa (Latin) ha-Latn 0x7C68 31848
Hausa (Latin, Ghana) ha-Latn-GH 0x1000 4096
Hausa (Latin, Niger) ha-Latn-NE 0x1000 4096
Hausa (Latin, Nigeria) ha-Latn-NG 0x468 1128
Hawaiian haw 0x75 117 Sunday
Hawaiian (United States) haw-US 0x475 1141 Sunday
Hebrew he 0xD 13 Sunday
Hebrew (Israel) he-IL 0x40D 1037 Sunday
Hindi hi 0x39 57
Hindi (India) hi-IN 0x439 1081
Hungarian hu 0xE 14
Hungarian (Hungary) hu-HU 0x40E 1038
Ibibio ibb 0x69 105 Sunday
Ibibio (Nigeria) ibb-NG 0x469 1129 Sunday
Icelandic is 0xF 15
Icelandic (Iceland) is-IS 0x40F 1039
Igbo ig 0x70 112
Igbo (Nigeria) ig-NG 0x470 1136
Indonesian id 0x21 33 Sunday
Indonesian (Indonesia) id-ID 0x421 1057 Sunday
Interlingua ia 0x1000 4096
Interlingua (France) ia-FR 0x1000 4096
Interlingua (World) ia-001 0x1000 4096
Inuktitut iu 0x5D 93 Sunday
Inuktitut (Latin) iu-Latn 0x7C5D 31837 Sunday
Inuktitut (Latin, Canada) iu-Latn-CA 0x85D 2141 Sunday
Inuktitut (Syllabics) iu-Cans 0x785D 30813 Sunday
Inuktitut (Syllabics, Canada) iu-Cans-CA 0x45D 1117 Sunday
Invariant Language (Invariant Country) 0x7F 127
Irish ga 0x3C 60 Sunday
Irish (Ireland) ga-IE 0x83C 2108 Sunday
isiXhosa xh 0x34 52 Sunday
isiXhosa (South Africa) xh-ZA 0x434 1076 Sunday
isiZulu zu 0x35 53 Sunday
isiZulu (South Africa) zu-ZA 0x435 1077 Sunday
Italian it 0x10 16
Italian (Italy) it-IT 0x410 1040
Italian (San Marino) it-SM 0x1000 4096
Italian (Switzerland) it-CH 0x810 2064
Italian (Vatican City) it-VA 0x1000 4096
Japanese ja 0x11 17 Sunday
Japanese (Japan) ja-JP 0x411 1041 Sunday
Javanese jv-Latn 0x1000 4096 Sunday
Javanese jv 0x1000 4096 Sunday
Javanese (Indonesia) jv-Latn-ID 0x1000 4096 Sunday
Javanese (Javanese) jv-Java 0x1000 4096 Sunday
Javanese (Javanese, Indonesia) jv-Java-ID 0x1000 4096 Sunday
Jola-Fonyi dyo 0x1000 4096
Jola-Fonyi (Senegal) dyo-SN 0x1000 4096
Kabuverdianu kea 0x1000 4096
Kabuverdianu (Cabo Verde) kea-CV 0x1000 4096
Kabyle kab 0x1000 4096 Saturday
Kabyle (Algeria) kab-DZ 0x1000 4096 Saturday
Kako kkj 0x1000 4096
Kako (Cameroon) kkj-CM 0x1000 4096
Kalenjin kln 0x1000 4096 Sunday
Kalenjin (Kenya) kln-KE 0x1000 4096 Sunday
Kamba kam 0x1000 4096 Sunday
Kamba (Kenya) kam-KE 0x1000 4096 Sunday
Kannada kn 0x4B 75
Kannada (India) kn-IN 0x44B 1099
Kanuri kr 0x71 113 Sunday
Kanuri (Nigeria) kr-NG 0x471 1137 Sunday
Kashmiri ks 0x60 96
Kashmiri (Devanagari) ks-Deva 0x1000 4096
Kashmiri (Devanagari, India) ks-Deva-IN 0x860 2144
Kashmiri (Perso-Arabic) ks-Arab 0x460 1120 Sunday
Kashmiri (Perso-Arabic) ks-Arab-IN 0x1000 4096 Sunday
Kazakh kk 0x3F 63
Kazakh (Kazakhstan) kk-KZ 0x43F 1087
Khmer km 0x53 83 Sunday
Khmer (Cambodia) km-KH 0x453 1107 Sunday
K'iche' quc-Latn 0x7C86 31878
K'iche' quc 0x86 134
K'iche' (Guatemala) quc-Latn-GT 0x486 1158
Kikuyu ki 0x1000 4096 Sunday
Kikuyu (Kenya) ki-KE 0x1000 4096 Sunday
Kinyarwanda rw 0x87 135
Kinyarwanda (Rwanda) rw-RW 0x487 1159
Kiswahili sw 0x41 65 Sunday
Kiswahili (Congo DRC) sw-CD 0x1000 4096
Kiswahili (Kenya) sw-KE 0x441 1089 Sunday
Kiswahili (Tanzania) sw-TZ 0x1000 4096
Kiswahili (Uganda) sw-UG 0x1000 4096
Konkani kok 0x57 87
Konkani (India) kok-IN 0x457 1111
Korean ko 0x12 18 Sunday
Korean (Korea) ko-KR 0x412 1042 Sunday
Korean (North Korea) ko-KP 0x1000 4096
Koyra Chiini khq 0x1000 4096
Koyra Chiini (Mali) khq-ML 0x1000 4096
Koyraboro Senni ses 0x1000 4096
Koyraboro Senni (Mali) ses-ML 0x1000 4096
Kurdish (Perso-Arabic, Iran) ku-Arab-IR 0x1000 4096 Saturday
Kwasio nmg 0x1000 4096
Kwasio (Cameroon) nmg-CM 0x1000 4096
Kyrgyz ky 0x40 64
Kyrgyz (Kyrgyzstan) ky-KG 0x440 1088
Lakota lkt 0x1000 4096 Sunday
Lakota (United States) lkt-US 0x1000 4096 Sunday
Langi lag 0x1000 4096
Langi (Tanzania) lag-TZ 0x1000 4096
Lao lo 0x54 84 Sunday
Lao (Lao P.D.R.) lo-LA 0x454 1108 Sunday
Latin la 0x76 118 Sunday
Latin (World) la-001 0x476 1142 Sunday
Latvian lv 0x26 38
Latvian (Latvia) lv-LV 0x426 1062
Lingala ln 0x1000 4096
Lingala (Angola) ln-AO 0x1000 4096
Lingala (Central African Republic) ln-CF 0x1000 4096
Lingala (Congo DRC) ln-CD 0x1000 4096
Lingala (Congo) ln-CG 0x1000 4096
Lithuanian lt 0x27 39
Lithuanian (Lithuania) lt-LT 0x427 1063
Low German nds 0x1000 4096
Low German (Germany) nds-DE 0x1000 4096
Low German (Netherlands) nds-NL 0x1000 4096
Lower Sorbian dsb 0x7C2E 31790
Lower Sorbian (Germany) dsb-DE 0x82E 2094
Luba-Katanga lu 0x1000 4096
Luba-Katanga (Congo DRC) lu-CD 0x1000 4096
Luo luo 0x1000 4096 Sunday
Luo (Kenya) luo-KE 0x1000 4096 Sunday
Luxembourgish lb 0x6E 110
Luxembourgish (Luxembourg) lb-LU 0x46E 1134
Luyia luy 0x1000 4096 Sunday
Luyia (Kenya) luy-KE 0x1000 4096 Sunday
Macedonian (Former Yugoslav Republic of Macedonia) mk-MK 0x42F 1071
Macedonian (FYROM) mk 0x2F 47
Machame jmc 0x1000 4096
Machame (Tanzania) jmc-TZ 0x1000 4096
Makhuwa-Meetto mgh 0x1000 4096 Sunday
Makhuwa-Meetto (Mozambique) mgh-MZ 0x1000 4096 Sunday
Makonde kde 0x1000 4096
Makonde (Tanzania) kde-TZ 0x1000 4096
Malagasy mg 0x1000 4096
Malagasy (Madagascar) mg-MG 0x1000 4096
Malay ms 0x3E 62
Malay (Brunei Darussalam) ms-BN 0x83E 2110
Malay (Latin, Singapore) ms-SG 0x1000 4096 Sunday
Malay (Malaysia) ms-MY 0x43E 1086
Malayalam ml 0x4C 76 Sunday
Malayalam (India) ml-IN 0x44C 1100 Sunday
Maltese mt 0x3A 58 Sunday
Maltese (Malta) mt-MT 0x43A 1082 Sunday
Manipuri mni 0x58 88
Manipuri (India) mni-IN 0x458 1112
Manx gv 0x1000 4096
Manx (Isle of Man) gv-IM 0x1000 4096
Maori mi 0x81 129
Maori (New Zealand) mi-NZ 0x481 1153
Mapudungun arn 0x7A 122 Sunday
Mapudungun (Chile) arn-CL 0x47A 1146 Sunday
Marathi mr 0x4E 78
Marathi (India) mr-IN 0x44E 1102
Masai mas 0x1000 4096 Sunday
Masai (Kenya) mas-KE 0x1000 4096 Sunday
Masai (Tanzania) mas-TZ 0x1000 4096
Mazanderani mzn 0x1000 4096 Saturday
Mazanderani (Iran) mzn-IR 0x1000 4096 Saturday
Meru mer 0x1000 4096 Sunday
Meru (Kenya) mer-KE 0x1000 4096 Sunday
Meta' mgo 0x1000 4096
Meta' (Cameroon) mgo-CM 0x1000 4096
Mohawk moh 0x7C 124 Sunday
Mohawk (Mohawk) moh-CA 0x47C 1148 Sunday
Mongolian mn 0x50 80
Mongolian (Cyrillic) mn-Cyrl 0x7850 30800
Mongolian (Cyrillic, Mongolia) mn-MN 0x450 1104
Mongolian (Traditional Mongolian) mn-Mong 0x7C50 31824
Mongolian (Traditional Mongolian, Mongolia) mn-Mong-MN 0xC50 3152
Mongolian (Traditional Mongolian, PRC) mn-Mong-CN 0x850 2128
Morisyen mfe 0x1000 4096
Morisyen (Mauritius) mfe-MU 0x1000 4096
Mundang mua 0x1000 4096
Mundang (Cameroon) mua-CM 0x1000 4096
Nama naq 0x1000 4096
Nama (Namibia) naq-NA 0x1000 4096
Nepali ne 0x61 97 Sunday
Nepali (India) ne-IN 0x861 2145 Sunday
Nepali (Nepal) ne-NP 0x461 1121 Sunday
Ngiemboon nnh 0x1000 4096
Ngiemboon (Cameroon) nnh-CM 0x1000 4096
Ngomba jgo 0x1000 4096
Ngomba (Cameroon) jgo-CM 0x1000 4096
N'ko nqo 0x1000 4096 Saturday
N'ko (Guinea) nqo-GN 0x1000 4096 Saturday
North Ndebele nd 0x1000 4096 Sunday
North Ndebele (Zimbabwe) nd-ZW 0x1000 4096 Sunday
Northern Luri lrc 0x1000 4096 Saturday
Northern Luri (Iran) lrc-IR 0x1000 4096 Saturday
Northern Luri (Iraq) lrc-IQ 0x1000 4096 Saturday
Norwegian no 0x14 20
Norwegian (Bokml) nb 0x7C14 31764
Norwegian (Nynorsk) nn 0x7814 30740
Norwegian, Bokml (Norway) nb-NO 0x414 1044
Norwegian, Bokml (Svalbard and Jan Mayen) nb-SJ 0x1000 4096
Norwegian, Nynorsk (Norway) nn-NO 0x814 2068
Nuer nus 0x1000 4096
Nuer (South Sudan) nus-SS 0x1000 4096
Nyankole nyn 0x1000 4096
Nyankole (Uganda) nyn-UG 0x1000 4096
Occitan oc 0x82 130
Occitan (France) oc-FR 0x482 1154
Odia or 0x48 72
Odia (India) or-IN 0x448 1096
Oromo om 0x72 114 Sunday
Oromo (Ethiopia) om-ET 0x472 1138 Sunday
Oromo (Kenya) om-KE 0x1000 4096 Sunday
Ossetian (Cyrillic, Georgia) os-GE 0x1000 4096
Ossetian (Cyrillic, Russia) os-RU 0x1000 4096
Ossetic os 0x1000 4096
Papiamento pap 0x79 121
Papiamento (Caribbean) pap-029 0x479 1145
Pashto ps 0x63 99 Saturday
Pashto (Afghanistan) ps-AF 0x463 1123 Saturday
Persian fa 0x29 41 Saturday
Persian (Iran) fa-IR 0x429 1065 Saturday
Polish pl 0x15 21
Polish (Poland) pl-PL 0x415 1045
Portuguese pt 0x16 22 Sunday
Portuguese (Angola) pt-AO 0x1000 4096
Portuguese (Brazil) pt-BR 0x416 1046 Sunday
Portuguese (Cabo Verde) pt-CV 0x1000 4096
Portuguese (Equatorial Guinea) pt-GQ 0x1000 4096
Portuguese (Guinea-Bissau) pt-GW 0x1000 4096
Portuguese (Luxembourg) pt-LU 0x1000 4096
Portuguese (Macao SAR) pt-MO 0x1000 4096 Sunday
Portuguese (Mozambique) pt-MZ 0x1000 4096 Sunday
Portuguese (Portugal) pt-PT 0x816 2070 Sunday
Portuguese (So Tomé and Príncipe) pt-ST 0x1000 4096
Portuguese (Switzerland) pt-CH 0x1000 4096
Portuguese (Timor-Leste) pt-TL 0x1000 4096
Prussian prg 0x1000 4096
Prussian (World) prg-001 0x1000 4096
Punjabi pa 0x46 70
Punjabi (Arabic) pa-Arab 0x7C46 31814
Punjabi (India) pa-IN 0x446 1094
Punjabi (Islamic Republic of Pakistan) pa-Arab-PK 0x846 2118
Quechua quz 0x6B 107 Sunday
Quechua (Bolivia) quz-BO 0x46B 1131 Sunday
Quechua (Ecuador) quz-EC 0x86B 2155 Sunday
Quechua (Peru) quz-PE 0xC6B 3179
Ripuarian (Germany) ksh-DE 0x1000 4096
Romanian ro 0x18 24
Romanian (Moldova) ro-MD 0x818 2072
Romanian (Romania) ro-RO 0x418 1048
Romansh rm 0x17 23
Romansh (Switzerland) rm-CH 0x417 1047
Rombo rof 0x1000 4096
Rombo (Tanzania) rof-TZ 0x1000 4096
Rundi rn 0x1000 4096
Rundi (Burundi) rn-BI 0x1000 4096
Russian ru 0x19 25
Russian (Belarus) ru-BY 0x1000 4096
Russian (Kazakhstan) ru-KZ 0x1000 4096
Russian (Kyrgyzstan) ru-KG 0x1000 4096
Russian (Moldova) ru-MD 0x819 2073
Russian (Russia) ru-RU 0x419 1049
Russian (Ukraine) ru-UA 0x1000 4096
Rwa rwk 0x1000 4096
Rwa (Tanzania) rwk-TZ 0x1000 4096
Saho ssy 0x1000 4096
Saho (Eritrea) ssy-ER 0x1000 4096
Sakha sah 0x85 133
Sakha (Russia) sah-RU 0x485 1157
Samburu saq 0x1000 4096 Sunday
Samburu (Kenya) saq-KE 0x1000 4096 Sunday
Sami (Inari) smn 0x703B 28731
Sami (Lule) smj 0x7C3B 31803
Sami (Northern) se 0x3B 59
Sami (Skolt) sms 0x743B 29755
Sami (Southern) sma 0x783B 30779
Sami, Inari (Finland) smn-FI 0x243B 9275
Sami, Lule (Norway) smj-NO 0x103B 4155
Sami, Lule (Sweden) smj-SE 0x143B 5179
Sami, Northern (Finland) se-FI 0xC3B 3131
Sami, Northern (Norway) se-NO 0x43B 1083
Sami, Northern (Sweden) se-SE 0x83B 2107
Sami, Skolt (Finland) sms-FI 0x203B 8251
Sami, Southern (Norway) sma-NO 0x183B 6203
Sami, Southern (Sweden) sma-SE 0x1C3B 7227
Sango sg 0x1000 4096
Sango (Central African Republic) sg-CF 0x1000 4096
Sangu sbp 0x1000 4096
Sangu (Tanzania) sbp-TZ 0x1000 4096
Sanskrit sa 0x4F 79 Sunday
Sanskrit (India) sa-IN 0x44F 1103 Sunday
Scottish Gaelic gd 0x91 145
Scottish Gaelic (United Kingdom) gd-GB 0x491 1169
Sena seh 0x1000 4096 Sunday
Sena (Mozambique) seh-MZ 0x1000 4096 Sunday
Serbian sr 0x7C1A 31770
Serbian (Cyrillic) sr-Cyrl 0x6C1A 27674
Serbian (Cyrillic, Bosnia and Herzegovina) sr-Cyrl-BA 0x1C1A 7194
Serbian (Cyrillic, Kosovo) sr-Cyrl-XK 0x1000 4096
Serbian (Cyrillic, Montenegro) sr-Cyrl-ME 0x301A 12314
Serbian (Cyrillic, Serbia) sr-Cyrl-RS 0x281A 10266
Serbian (Latin) sr-Latn 0x701A 28698
Serbian (Latin, Bosnia and Herzegovina) sr-Latn-BA 0x181A 6170
Serbian (Latin, Kosovo) sr-Latn-XK 0x1000 4096
Serbian (Latin, Montenegro) sr-Latn-ME 0x2C1A 11290
Serbian (Latin, Serbia) sr-Latn-RS 0x241A 9242
Sesotho (Lesotho) st-LS 0x1000 4096
Sesotho sa Leboa nso 0x6C 108 Sunday
Sesotho sa Leboa (South Africa) nso-ZA 0x46C 1132 Sunday
Setswana tn 0x32 50 Sunday
Setswana (Botswana) tn-BW 0x832 2098 Sunday
Setswana (South Africa) tn-ZA 0x432 1074 Sunday
Shambala ksb 0x1000 4096
Shambala (Tanzania) ksb-TZ 0x1000 4096
Shona sn 0x1000 4096 Sunday
Shona (Latin) sn-Latn 0x1000 4096 Sunday
Shona (Latin, Zimbabwe) sn-Latn-ZW 0x1000 4096 Sunday
Sindhi sd 0x59 89
Sindhi (Arabic) sd-Arab 0x7C59 31833
Sindhi (Devanagari) sd-Deva 0x1000 4096 Sunday
Sindhi (Devanagari, India) sd-Deva-IN 0x459 1113 Sunday
Sindhi (Islamic Republic of Pakistan) sd-Arab-PK 0x859 2137
Sinhala si 0x5B 91
Sinhala (Sri Lanka) si-LK 0x45B 1115
Slovak sk 0x1B 27
Slovak (Slovakia) sk-SK 0x41B 1051
Slovenian sl 0x24 36
Slovenian (Slovenia) sl-SI 0x424 1060
Soga xog 0x1000 4096
Soga (Uganda) xog-UG 0x1000 4096
Somali so 0x77 119
Somali (Djibouti) so-DJ 0x1000 4096 Saturday
Somali (Ethiopia) so-ET 0x1000 4096 Sunday
Somali (Kenya) so-KE 0x1000 4096 Sunday
Somali (Somalia) so-SO 0x477 1143
South Ndebele nr 0x1000 4096 Sunday
South Ndebele (South Africa) nr-ZA 0x1000 4096 Sunday
Southern Sotho st 0x30 48
Southern Sotho (South Africa) st-ZA 0x430 1072
Spanish es 0xA 10
Spanish (Argentina) es-AR 0x2C0A 11274 Sunday
Spanish (Belize) es-BZ 0x1000 4096 Sunday
Spanish (Venezuela) es-VE 0x200A 8202
Spanish (Bolivia) es-BO 0x400A 16394
Spanish (Brazil) es-BR 0x1000 4096
Spanish (Chile) es-CL 0x340A 13322
Spanish (Colombia) es-CO 0x240A 9226 Sunday
Spanish (Costa Rica) es-CR 0x140A 5130
Spanish (Cuba) es-CU 0x5C0A 23562
Spanish (Dominican Republic) es-DO 0x1C0A 7178 Sunday
Spanish (Ecuador) es-EC 0x300A 12298
Spanish (El Salvador) es-SV 0x440A 17418 Sunday
Spanish (Equatorial Guinea) es-GQ 0x1000 4096
Spanish (Guatemala) es-GT 0x100A 4106 Sunday
Spanish (Honduras) es-HN 0x480A 18442 Sunday
Spanish (Latin America) es-419 0x580A 22538
Spanish (Mexico) es-MX 0x80A 2058 Sunday
Spanish (Nicaragua) es-NI 0x4C0A 19466 Sunday
Spanish (Panama) es-PA 0x180A 6154 Sunday
Spanish (Paraguay) es-PY 0x3C0A 15370 Sunday
Spanish (Peru) es-PE 0x280A 10250 Sunday
Spanish (Philippines) es-PH 0x1000 4096 Sunday
Spanish (Puerto Rico) es-PR 0x500A 20490 Sunday
Spanish (Spain) es-ES 0xC0A 3082
Spanish (United States) es-US 0x540A 21514 Sunday
Spanish (Uruguay) es-UY 0x380A 14346
Standard Moroccan Tamazight zgh 0x1000 4096 Saturday
Standard Moroccan Tamazight (Tifinagh) zgh-Tfng 0x1000 4096 Saturday
Standard Moroccan Tamazight (Tifinagh, Morocco) zgh-Tfng-MA 0x1000 4096 Saturday
Swati ss 0x1000 4096
Swati (South Africa) ss-ZA 0x1000 4096
Swati (Eswatini former Swaziland) ss-SZ 0x1000 4096
Swedish sv 0x1D 29
Swedish (land Islands) sv-AX 0x1000 4096
Swedish (Finland) sv-FI 0x81D 2077
Swedish (Sweden) sv-SE 0x41D 1053
Syriac syr 0x5A 90 Sunday
Syriac (Syria) syr-SY 0x45A 1114 Sunday
Tachelhit shi 0x1000 4096 Saturday
Tachelhit (Latin) shi-Latn 0x1000 4096 Saturday
Tachelhit (Latin, Morocco) shi-Latn-MA 0x1000 4096 Saturday
Tachelhit (Tifinagh) shi-Tfng 0x1000 4096 Saturday
Tachelhit (Tifinagh, Morocco) shi-Tfng-MA 0x1000 4096 Saturday
Taita dav 0x1000 4096 Sunday
Taita (Kenya) dav-KE 0x1000 4096 Sunday
Tajik tg 0x28 40
Tajik (Cyrillic) tg-Cyrl 0x7C28 31784
Tajik (Cyrillic, Tajikistan) tg-Cyrl-TJ 0x428 1064
Tamazight tzm 0x5F 95
Tamazight (Latin) tzm-Latn 0x7C5F 31839
Tamazight (Latin, Algeria) tzm-Latn-DZ 0x85F 2143
Tamazight (Tifinagh) tzm-Tfng 0x785F 30815
Tamil ta 0x49 73
Tamil (India) ta-IN 0x449 1097
Tamil (Malaysia) ta-MY 0x1000 4096
Tamil (Singapore) ta-SG 0x1000 4096 Sunday
Tamil (Sri Lanka) ta-LK 0x849 2121
Tasawaq twq 0x1000 4096
Tasawaq (Niger) twq-NE 0x1000 4096
Tatar tt 0x44 68
Tatar (Russia) tt-RU 0x444 1092
Telugu te 0x4A 74
Telugu (India) te-IN 0x44A 1098
Teso teo 0x1000 4096
Teso (Kenya) teo-KE 0x1000 4096 Sunday
Teso (Uganda) teo-UG 0x1000 4096
Thai th 0x1E 30
Thai (Thailand) th-TH 0x41E 1054
Tibetan bo 0x51 81
Tibetan (India) bo-IN 0x1000 4096 Sunday
Tibetan (PRC) bo-CN 0x451 1105
Tigre tig 0x1000 4096
Tigre (Eritrea) tig-ER 0x1000 4096
Tigrinya ti 0x73 115
Tigrinya (Eritrea) ti-ER 0x873 2163
Tigrinya (Ethiopia) ti-ET 0x473 1139 Sunday
Tongan to 0x1000 4096
Tongan (Tonga) to-TO 0x1000 4096
Tsonga ts 0x31 49 Sunday
Tsonga (South Africa) ts-ZA 0x431 1073
Turkish tr 0x1F 31
Turkish (Cyprus) tr-CY 0x1000 4096
Turkish (Turkey) tr-TR 0x41F 1055
Turkmen tk 0x42 66
Turkmen (Turkmenistan) tk-TM 0x442 1090
Ukrainian uk 0x22 34
Ukrainian (Ukraine) uk-UA 0x422 1058
Upper Sorbian hsb 0x2E 46
Upper Sorbian (Germany) hsb-DE 0x42E 1070
Urdu ur 0x20 32
Urdu (India) ur-IN 0x820 2080
Urdu (Islamic Republic of Pakistan) ur-PK 0x420 1056
Uyghur ug 0x80 128
Uyghur (PRC) ug-CN 0x480 1152
Uzbek uz 0x43 67
Uzbek (Cyrillic) uz-Cyrl 0x7843 30787
Uzbek (Cyrillic, Uzbekistan) uz-Cyrl-UZ 0x843 2115
Uzbek (Latin) uz-Latn 0x7C43 31811
Uzbek (Latin, Uzbekistan) uz-Latn-UZ 0x443 1091
Uzbek (Perso-Arabic) uz-Arab 0x1000 4096 Saturday
Uzbek (Perso-Arabic, Afghanistan) uz-Arab-AF 0x1000 4096 Saturday
Vai vai 0x1000 4096
Vai (Latin) vai-Latn 0x1000 4096
Vai (Latin, Liberia) vai-Latn-LR 0x1000 4096
Vai (Vai) vai-Vaii 0x1000 4096
Vai (Vai, Liberia) vai-Vaii-LR 0x1000 4096
Valencian (Spain) ca-ES-valencia 0x803 2051
Venda ve 0x33 51 Sunday
Venda (South Africa) ve-ZA 0x433 1075 Sunday
Vietnamese vi 0x2A 42
Vietnamese (Vietnam) vi-VN 0x42A 1066
Volapük vo 0x1000 4096
Volapük (World) vo-001 0x1000 4096
Vunjo vun 0x1000 4096
Vunjo (Tanzania) vun-TZ 0x1000 4096
Walser wae 0x1000 4096
Walser (Switzerland) wae-CH 0x1000 4096
Welsh cy 0x52 82
Welsh (United Kingdom) cy-GB 0x452 1106
Wolaytta wal 0x1000 4096 Sunday
Wolaytta (Ethiopia) wal-ET 0x1000 4096 Sunday
Wolof wo 0x88 136
Wolof (Senegal) wo-SN 0x488 1160
Yangben yav 0x1000 4096
Yangben (Cameroon) yav-CM 0x1000 4096
Yi ii 0x78 120
Yi (PRC) ii-CN 0x478 1144
Yiddish yi 0x3D 61
Yiddish (World) yi-001 0x43D 1085
Yoruba yo 0x6A 106
Yoruba (Benin) yo-BJ 0x1000 4096
Yoruba (Nigeria) yo-NG 0x46A 1130
Zarma dje 0x1000 4096
Zarma (Niger) dje-NE 0x1000 4096
The locale identifier LOCALE_CUSTOM_UNSPECIFIED (0x1000, or 4096) is assigned to any culture that does not have a unique locale identifier and does not have complete system-provided data. Not all software packages will fully support all locales, so for example SQL database sort orders may not handle alphabetical sorting for every locale correctly even when the OS does. Related: Time Zones Language Identifier Constants and Strings - MSDN. PowerShell script to generate this page. ISO 3166 - Codes for countries and dependent territories. ISO 639-1 - Codes for languages. ISO 8601 - Standard date and time notation. CHCP - active console Code Page.

WScript.GetObject

Retrieve an Automation object (assumes there is a current instance of the object) Syntax Set objObject = Wscript.GetObject(strPathname [,strProgID] ], [strPrefix]) Arguments: strPathname : The pathname of the file containing the object to retrieve. (required) strProgID : The program identifier (ProgID) of the object. strPrefix : A prefix for subroutine names (optional) e.g. if strPrefix is "MYOBJ_" and the object fires an event named "OnBegin," WSH calls the subroutine "MYOBJ_OnBegin" objObject is an Automation object. GetObject is a wscript method. Example Open a copy of the Excel application: Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add objExcel.Cells(1, 1).Value = "Some demonstration text" Open an Excel file: Set objExcelFile = GetObject("C:\demo\example.xlsx") WScript.Echo objExcelFile.Name objExcelFile.Close “When I take action I'm not going to fire a $2 million missile at a $10 empty tent and hit a camel in the butt. It's going to be decisive” ~ George W Bush, 2001 Related: .CreateObject - Create a WSH automation object. .ConnectObject - Connect to a COM object. .DisconnectObject - Disconnect from a COM object.

Hex

Return the hex value of number Syntax Hex (number) Key number The number to convert to hex. If number is not already a whole number, it is rounded to the nearest whole number before being evaluated. If number is Null, Hex() returns Null. If number is Empty, Hex() returns Zero (0). If number is any other number, Hex() returns up to eight hexadecimal characters. You can represent hexadecimal numbers directly by preceding numbers in the proper range with &H. For example, &H10 represents decimal 16 in hexadecimal notation. Examples Dim MyHex MyHex = Hex(5) ' Returns 5. MyHex = Hex(10) ' Returns A. MyHex = Hex(459) ' Returns 1CB. “The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris Related: Int - Return the integer portion of a number.

Hour

Return the hour of the day (24 hour format - a number from 0 to 23) from a given time value. Syntax Hour(time_value) Key time_value A valid time. Examples Dim intDemo intDemo = Hour(dtmShiftEnd) intDemo = Hour(#08:55:00 AM#) intDemo = Hour(#30/12/2012 08:55:00 AM#) Select * from orders where Hour(Order_date) = 17; “What would be the use of immortality to a person who cannot use well a half an hour” ~ Ralph Waldo Emerson Related: Day - Return the day of the month. DatePart - Return part of a given date. Minute - Return the minute of the hour. GetDate.vbs - Return the current Year/month/Day and time.

If ... Then...Else

Repeat a block of statements. Syntax If condition Then [Statements] [Else Else-Statements] or If condition Then [Statements] [ElseIf condition-n] Then [Statements] [Else] [Statements] End If Key condition An expression that evaluates to True or False Statements Program code to be executed if condition is True Case sensitivity - the VBScript IF statement will always do a Case-Sensitive comparison: IF "New York" = "new york" THEN ... will evaluate as false. To make a comparison Case-insensitive, you can use either the UCase() or LCase() functions: IF UCase("New York") = UCase("new york") THEN ... Examples hournow = hour(Time()) If hournow > 12 Then WScript.Echo "Good Afternoon" Dim strCountry strCountry = "USA" If strCountry = "USA" Then WScript.Echo "United States of America." ElseIf strCountry = "CA" Then WScript.Echo "Canada." Else WScript.Echo "Some other country." End If “You have to learn the rules of the game. And then you have to play better than anyone else” ~ Albert Einstein Related: Select...Case - Conditional execution of a block of code. Do..Loop - Repeat a block of statements. While...Wend - Conditionally repeat a block of statements. Equivalent in PowerShell: If

InputBox

Prompt for user input. Syntax InputBox(prompt[, title][, default] [, xpos][, ypos][, helpfile, context]) Key prompt The dialogue box prompt text. title Title bar text default A default string to display xpos Distance from the left ypos Distance from the top helpfile A helpfile to link to the help button context Helpfile context number Input box returns a string containing the text entered Examples 'Prompt for a message and then display it: strMessage =Inputbox("Enter your message","Input Required") WScript.Echo strMessage :: Get user input from a CMD script and store in a variable: @echo off SETLOCAL SET _prompt=%1 ::Create the VBS script with an echo statement: ECHO Wscript.Echo Inputbox("Enter %_prompt%","Input Required")>%TEMP%\~input.vbs :s_GetInput :: Run the vbScript and save the output FOR /f "delims=/" %%G IN ('cscript //nologo %TEMP%\~input.vbs') DO set _string=%%G :: Delete the VBS file DEL %TEMP%\~input.vbs :: Display the result SET _string ENDLOCAL & SET _input=%_string% “Everyone has an invisible sign hanging from their neck saying, Make me feel important. Never forget this message when working with people” ~ Mary Kay Ash Related: MsgBox - Display a dialogue box message. Equivalent PowerShell cmdlet: Read-Host

InStr

Return the position of the first occurrence of one string within another. Syntax InStr([start, ]string1, string2[, compare]) Key string1 The initial string of Text string2 The text we want to find in String1 Start Character position in string1 at which to start the search Compare Either vbBinaryCompare or VBTextCompare Example result = InStr("Hello World", "wor") WScript.Echo result “Who looks outside, dreams; who looks inside, awakes” ~ Carl Gustav Jung Related: InStrRev - Find one string within another, starting from the end. Replace - Find and replace text. Equivalent in PowerShell: $result = $myvar.indexof("demo") Also .contains("demo") returns True/False

InStrRev

Return the position of the first occurrence of one string within another, from the end of string. Syntax InStrRev(string1, string2 [,start][, compare]) Key string1 The initial string of Text string2 The text we want to find in String1 Start Character position in string1 at which to start the search Compare Either vbBinaryCompare or VBTextCompare Example result = InStrRev("A B A B", "A", 6) WScript.Echo result “Who looks outside, dreams; who looks inside, awakes” ~ Carl Gustav Jung Related: InStr - Find one string within another. Replace - Find and replace text. Equivalent in PowerShell: $result = $myvar.lastindexofany("A")

Int

Return the integer portion of a number. Syntax Int(expression) Key expression A numeric expression. The Int() function returns numbers without the fractional part. Negative numbers will be rounded down by Int(). Examples Dim dblDemo as Double dblDemo = Int(123.45) Returns 123 dblDemo = Int(-123.45) Returns -124 Int() is often used to calculate age from a date of birth so that 30.9 years will display as 30 years old: int((now()-birthdate)/365.25) “Superstition sets the whole world in flames; philosophy quenches them” ~ Voltaire Related: Abs - The absolute value of a number (ignore negative sign). Fix - Return the integer portion of a number (negative numbers round up).

IsArray

Returns a Boolean value indicating whether a variable is an array. Syntax IsArray(Variable_Name) Key Variable_Name Any variable. IsArray returns True if the variable is an array; otherwise, it returns False. IsArray is especially useful with variants containing arrays. Examples Test whether MyVariable is an array: Dim MyVariable Dim MyArray(3) MyArray(0) = "Sunday" MyArray(1) = "Monday" MyArray(2) = "Tuesday" MyVariable = IsArray(MyArray) ' MyVariable contains "True". “The trouble with Buddhism ?-- in order to free oneself of all desire, one has to desire to do so” ~ Henry Miller Related: IsNumeric - Is expression a Numeric?

IsDate

Return TRUE if the expression is a valid date, otherwise return FALSE. Syntax IsDate(expression) Keyw expression A numeric expression. The IsDate() function can be used in VBA or in an SQL query. Examples Dim boolTest as Boolean boolTest = IsDate(#1/3/2015#) Returns True boolTest = IsDate("January 14, 2014") Returns True boolTest = IsDate("SS64") Returns False “Superstition sets the whole world in flames; philosophy quenches them” ~ Voltaire Related: IsNull - Is expression NULL? True/False

IsEmpty

Returns a Boolean value indicating whether a variable has been initialized. Syntax IsEmpty(expression) Key expression Any expression. However, because IsEmpty() is used to determine if variables are initialized, this is most often a variable name. IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False. False is always returned if expression contains more than one variable. Examples Test whether a variable has been initialized: Dim MyVar, MyCheck MyCheck = IsEmpty(MyVar) ' Returns True. MyVar = Null MyCheck = IsEmpty(MyVar) ' Returns False. MyVar = Empty MyCheck = IsEmpty(MyVar) ' Returns True. “I have no money, no resources, no hopes. I am the happiest man alive” ~ Henry Miller Related: Syntax - IsBlank function to detect Empty or NULL or Zero.

IsNull

Return TRUE if the expression is NULL, otherwise return FALSE. Syntax IsNull(expression) Key expression A string or numeric expression. VBScript makes a distinction between an empty string "" and a NULL value. IsNull() will only detect NULLs. Examples Dim boolDemo boolDemo = IsNull(Me!txtDescription) If boolDemo = True Then Msgbox "A required value is missing!" “Art is the elimination of the unnecessary” ~ Pablo Picasso Related: Syntax - IsBlank function to detect Empty or NULL or Zero.

IsNumeric

Return TRUE if the expression is a valid number, otherwise return FALSE. Syntax IsNumeric(expression) Key expression A string or numeric expression. Examples Dim boolDemo boolDemo = IsNumeric(123.45) Returns True boolDemo = IsNumeric("123.45") Returns True boolDemo = IsNumeric("SS64") Returns False “Art is the elimination of the unnecessary” ~ Pablo Picasso Related: Syntax - IsBlank function to detect Empty or NULL or Zero.

IsObject

Returns a Boolean value indicating whether an expression references a valid Automation object. Syntax IsObject(expression) Key expression Any expression. IsObject returns True if expression is a variable of Object subtype or a user-defined object; otherwise, it returns False. Examples Test if an identifier represents an object variable: Dim MyInt, MyCheck, MyObject Set MyObject = Me MyCheck = IsObject(MyObject) ' Returns True. MyCheck = IsObject(MyInt) ' Returns False. “I have no money, no resources, no hopes. I am the happiest man alive” ~ Henry Miller Related: Syntax - IsBlank function to detect Empty or NULL or Zero.

Join

Combine a number of substrings contained in a list (array) into a single string value. Syntax Join(list[, delimiter]) Key list A one-dimensional array containing substrings to be joined. delimiter A string character used to separate the substrings in the returned string. If omitted, the space character (" ") is used. If delimiter is a zero-length string, all items in the list are concatenated with no delimiters. Example join the substrings of MyArray: Dim MyString Dim MyArray(3) MyArray(0) = "Mr." MyArray(1) = "John " MyArray(2) = "Doe " MyArray(3) = "III" MyString = Join(MyArray) ' MyString contains "Mr. John Doe III". “There's zero correlation between being the best talker and having the best ideas” ~ Susan Cain Related: Array - Add values to an Array variable. Split - Parse a string of delimited values into an array.

LBound

Return the smallest available subscript for an array dimension. Syntax LBound(arrayname[, dimension]) Key arrayname The name of the array variable dimension The array dimension as a whole number 1 for the first dimension, 2 for the second etc (default=1) The LBound function is used with the UBound Function to determine the size of an array. Use UBound to find the upper limit of an array dimension. The default lower bound for any dimension is always 0. Example Dim Arr(5,10,12) result = LBound(Arr, 1) WScript.Echo result “Who looks outside, dreams; who looks inside, awakes” - Carl Gustav Jung Related: Array(el1,el2,el3) - Add values to an Array variable. Dim - Declare a new variable or array variable. UBound - Return the largest subscript for an array dimension. Equivalent in PowerShell: $arrDemo.getupperbound(0) or $arrDemo.length-1

Lcase

Convert a string to lower-case. Syntax Lcase(string) Key string A string or string expression. Examples Dim strDemo strDemo = Lcase("12 ACACIA Gardens") Msgbox strDemo Returns "12 acacia gardens" “Graze on my lips, and if those hills be dry, Stray lower, where the pleasant fountains lie” ~ Shakespeare (Venus and Adonis) Related: UCase - Uppercase String If..Then - Conditionally execute a block of statements.

Left

Extract a substring from a string, starting from the left-most character. Syntax Left(string, NumberOfCharacters) Key string A string or string expression. NumberOfCharacters The Number of characters to return Examples Dim strDemo strDemo = Left("The world is everlasting", 9 ) Msgbox strDemo Returns "The world" “Begin at the beginning, the King said, very gravely, and go on till you come to the end: then stop” ~ Lewis Carroll Related: Mid - Extract a substring from a string. Right - Extract a substring from a string.

Len

Returns the length of a string. Syntax Len(string) Key string A string or string expression. Examples Dim intDemo IntDemo = Len("The world is everlasting") Returns 24 “Begin at the beginning, the King said, very gravely, and go on till you come to the end: then stop” ~ Lewis Carroll Related: Left - Extract a substring from a string. Right - Extract a substring from a string.

Log

Returns the natural logarithm of a number. Syntax Log (Number) Key number Any valid numeric expression greater than 0. The natural logarithm is the logarithm to the base e. The constant e is approximately 2.718282. Calculate base-n logarithms for any number x by dividing the natural logarithm of x by the natural logarithm of n as follows: Logn(x) = Log(x) / Log(n) A custom Function to calculate base-10 logarithms: Function Log10(X) Log10 = Log(X) / Log(10) End Function “Gold is the money of kings; silver is the money of gentlemen; barter is the money of peasants; but debt is the money of slaves” ~ Norm Franz Related: Exp(n) - Return e (base of natural logs) raised to a power n.

.Logevent

Log an event in the Windows event log. Syntax objShell.LogEvent intType, strMessage [,strTarget] Arguments: objShell A WScript.Shell object intType The type of the event is specified by (see details below). strMessage The message string is specified by. strTarget The name of the system where the event should be logged (default is local system). intType 0 SUCCESS 1 ERROR 2 WARNING 4 INFORMATION 8 AUDIT_SUCCESS 16 AUDIT_FAILURE Returns True if an event is logged sucessfully, otherwise it returns False. Examples Set objShell = CreateObject("WScript.Shell") objShell.LogEvent 4, "Script started." objShell.LogEvent 2, "An error occured." objShell.LogEvent 0, "Something worked." objShell.LogEvent 1, "Something failed." “You are no bigger then the things that annoy you” ~ Jerry Bundsen Equivalent Windows CMD command: EVENTCREATE - Add a message to the Windows event log.

Ltrim

Remove leading spaces from a string. Syntax Ltrim(string) Key string A text string or string expression. Examples Dim strDemo strDemo = Ltrim(" The world is everlasting") Returns "The world is everlasting" “The hands of every clock are shears, trimming us away scrap by scrap, and every time piece with a digital readout blinks us towards implosion” ~ Dean Koontz Related: Left - Extract a substring from a string. RTrim - Remove trailing spaces from a string. Trim - Remove leading and trailing spaces from a string.

.MapNetworkDrive

Add a shared network drive mapping. Syntax objNetwork.MapNetworkDrive(strLocalDrive, strRemoteShare, [persistent], [strUser], [strPassword]) Key objNetwork : A WScript.network object strLocalDrive : The drive letter (e.g. L:) strRemoteShare : The UNC path to the remote drive \\MyServer\MyPrinter (String value) persistent : True/False - store the mapping persistently in the users profile default = false strUser : The user name. (Optional) strPassword : The password. (Optional) Example Dim objNetwork, strRemoteShare Set objNetwork = WScript.CreateObject("WScript.Network") strRemoteShare = "\\myserver\users" objNetwork.MapNetworkDrive "H:", strRemoteShare, False To run these commands in PowerShell without calling cscript: $network = New-Object -ComObject WScript.Network $RemoteShare = '\\myserver\users' $network.MapNetworkDrive('H:', $RemoteShare, $false) The example script below takes this a stage further, disconnecting the drive letter first (and coded to cope with persistent and/or disconnected drive shares) DriveMap.vbs - Connect a local drive letter to a remote file share For workgroup machines sharing files via pass-thru authentication with no domain login script, a persistent drive map can be used. Persistent drives will automatically connect to the resource whenever it is available. “The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side” ~ James Baldwin Related: NET, list drive mappings - .EnumNetworkDrives NET, remove drive map - .RemoveNetworkDrive Equivalent Windows CMD command: NET - Manage network resources Equivalent PowerShell command: New-PSDrive - Create a mapped network drive.

Mid

Return a mid-section from a string. Syntax Mid(string , start [, length] Key string The text string (or string expression). start The start position of the substring length The length of the substring i.e. number of characters to return Examples 'Display a message: strSample="Partnum45" WScript.Echo Mid(strSample,8,2) > 45 “I would rather wake up in the middle of nowhere than in any city on earth” - Steve Mcqueen Related: Left - Extract a substring from a string Right - Return the rightmost len characters of string Equivalent in PowerShell: $result = $myvar.substring(2,3)

Minute

Return the minute of the hour (a number from 0 to 59) given a time value. Syntax Minute(time_value) Key time_value A valid time. Examples Dim intDemo intDemo = minute(dtmShiftEnd) intDemo = minute(#08:55:30 AM#) “For a moment, nothing happened. Then, after a second or so, nothing continued to happen” ~ Douglas Adams Related: Day - Return the day of the month. DatePart - Return part of a given date. Second - Return the seconds of the minute. GetDate.vbs - Return the current Year/month/Day and time.

Month

Return the month (a number from 1 to 12) for a given date. Syntax Month(date_value) Key date_value A valid date. Examples Dim intDemo intDemo = Month(dtmShiftEnd) intDemo = Month(#30/12/2012 08:55:00 AM#) “What would be the use of immortality to a person who cannot use well a half an hour” ~ Ralph Waldo Emerson Related: Day - Return the day of the month. DatePart - Return part of a given date. Year - Return the year for a given date. GetDate.vbs - Return the current Year/month/Day and time.

MonthName

Convert a month number to a descriptive Month. Syntax MonthName(number [,abbreviate]) Key number The month number (1-12). abbreviate True or False, abbreviate the month i.e. Jan or January Examples 'Display a message: WScript.Echo MonthName(12) > December “April is the cruelest month, breeding lilacs out of the dead land, mixing memory and desire, stirring dull roots with spring rain” ~ T.S. Eliot Related: InputBox - Prompt for user input Equivalent PowerShell cmdlet: Get-Date -f "MMMM"

MsgBox

Display a dialogue box message. Syntax MsgBox(prompt [, buttons][, title] [, helpfile, context]) Key prompt The dialogue box text. buttons The sum of the constants for button, icon, default button and modality title Title bar text helpfile A helpfile to link to the help button context Helpfile context number Constants Buttons: vbOKOnly (0), vbOKCancel(1), vbAbortRetryIgnore (2), vbYesNoCancel(3) vbYesNo (4), vbRetryCancel (5) Icon: vbCritical (16),vbQuestion (32),vbExclamation (48), vbInformation (64) Default button: vbDefaultButton1 (0),vbDefaultButton2 (256),vbDefaultButton3 (512),vbDefaultButton4(768) Modality: vbApplicationModal, vbSystemModal The MsgBox function will return one of the following: 1 = OK was clicked (vbOK) 2 = Cancel was clicked (vbCancel ) 3 = Abort was clicked (vbAbort) 4 = Retry was clicked (vbRetry) 5 = Ignore was clicked (vbIgnore) 6 = Yes was clicked (vbYes) 7 = No was clicked (vbNo) Examples 'Display a message: result=Msgbox("Are you sure?",vbYesNo+vbInformation, "") WScript.Echo result “Everyone has an invisible sign hanging from their neck saying, Make me feel important. Never forget this message when working with people” ~ Mary Kay Ash Related: InputBox - Prompt for user input. Equivalent PowerShell: MessageBox - Display a message box to the user.

The wscript.Network object

Provides access to the shared resources on the network to which your computer is connected. Syntax Set WshNetwork = CreateObject("Wscript.Network") Properties: UserName The username variable, likely the SAM Account Name (the pre-Windows 2000 name) UserDomain The NetBIOS domain name ComputerName This is the NetBIOS computer name Methods AddWindowsPrinterConnection Add a printer in Windows 2000 and higher AddPrinterConnection Add a printer in older systems EnumNetworkDrives List the mapped drives on the computer EnumPrinterConnections List the installed printers MapNetworkDrive Map a network drive RemoveNetworkDrive Remove a network drive RemovePrinterConnection Remove a printer connection SetDefaultPrinter Set the default printer Example Set WshNetwork = WScript.CreateObject("WScript.Network") WScript.Echo "Domain = " & WshNetwork.UserDomain WScript.Echo "Computer Name = " & WshNetwork.ComputerName WScript.Echo "User Name = " & WshNetwork.UserName “It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne Related: Shell + Shell.Application objects/methods.

Now

Return the current date and time. Syntax Now Example dim dtmCreated dtmCreated = Now “Beauty is Nature's coin, must not be hoarded, but must be current” ~ John Milton Related: DatePart - Return part of a given date. Date - The current date.

On Error

Error handling in VBScript is very basic, there is no option to immediately branch to an error handling routine. VBScript does not support GoTo or labels that would allow a program jump. When error handling is enabled, execution will continue onto the next line. To trap an error you have to explicitly test the err object to see if it holds an error. Syntax On Error resume next - Enable error handling On Error goto 0 - Disable error handling Error properties: err.Number (default) err.Source err.Description Examples In the examples below - replace the 'code goes here' line with your VBScript commands. Example 1) Trap an error On Error Resume Next ' code goes here If Err.Number <> 0 Then 'error handling: WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End If Example 2) Trap an error or success On Error Resume Next ' code goes here If Err.Number = 0 Then WScript.Echo "It worked!" Else WScript.Echo "Error:" WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End If Example 3) Trap an error On Error Resume Next ' code goes here If Err.Number <> 0 Then ShowError("It failed") Sub ShowError(strMessage) WScript.Echo strMessage WScript.Echo Err.Number & " Srce: " & Err.Source & " Desc: " & Err.Description Err.Clear End Sub “Success is falling nine times and getting up ten” ~ Jon Bon Jovi Related: Syntax - error codes InputBox - Prompt for user input. Equivalent in PowerShell: ErrorAction and $errorActionPreference

Dim

Explicitly declare a new variable or array variable. Syntax Dim Varname[([subscript])] [,Varname[([subscript])] ...] Key Varname Name for the new variable. subscript For an array variable, the maximum number of array elements. This is zero based so 4 will create a variable with 5 elements, and 0 will create an array with 1 element. Dim statements are not required unless the VBScript contains an Option Explicit statement. Unlike many other languages there is no need to specify a data type (integer, string, object etc) All VBScript variables are variants. You can choose a variable name that indicates the data type to be stored e.g. strEmployee, but this is not enforced. Examples Option explicit Dim myString, price myString="Hello world" price=123 Create an Array Variable with 3 elements: Dim strPrintQueues(2) strPrintQueues(0)="HP Deskjet 1200" strPrintQueues(1)="Kyocera first floor" strPrintQueues(2)="Mikes printer" “Listen to many, speak to a few” ~ William Shakespeare Related: Array - Add values to an Array variable. Private VarName - Declare a local variable/array variable. Public VarName - Declare a public variable/array variable. Equivalent PowerShell cmdlet: $MyVariable = SomeValue

.AddPrinterConnection

Add a printer connection. Syntax objNetwork.AddPrinterConnection(strLocalName, strRemoteName[,bUpdateProfile][,strUser][,strPassword] Key objNetwork : A WScript.network object strLocalName : Local printer Name (String value) strRemoteName : Remote printer Name (String value) bUpdateProfile : Indicate whether the printer mapping is stored in the current user's profile. Boolean value If TRUE the mapping is stored in the user profile. default = false. strUser : The user name. (if using a different profile) Optional. strPassword : The user password. (if using a different profile) Optional. The AddPrinterConnection method adds a network printer to an MS-DOS printer port, such as LPT1. To add a remote Windows-based printer connection, use the AddWindowsPrinterConnection method. Example ' Connect a network printer to LPT1. Set objNetwork = WScript.CreateObject("WScript.Network") objNetwork.AddPrinterConnection "LPT1", "\\Server\Print1" “Pay attention. It's all about paying attention. attention is vitality. It connects you with others. It makes you eager. stay eager” ~ Susan Sontag Related: Add Network printer - .AddWindowsPrinterConnection printcon.vbs - change a Print connection to a different Queue/Server. NET VIEW - to view a list of printers. NET PRINT - View and Delete print jobs. PRNCNFG - Display, configure or rename a printer. PRNDRVR - Add, delete or list printer drivers. PRNMNGR - Add, delete, or list printers / connections, set the default printer. Network Printing - Advice & Tips.

WshNetwork.AddWindowsPrinterConnection

MAP a Network (remote) Printer Syntax myObject.AddWindowsPrinterConnection(strLocalName UNC_Printer_Name) Example Dim net Set net = CreateObject("WScript.Network") net.AddWindowsPrinterConnection "\\ServerName\PrinterName" or net.AddWindowsPrinterConnection "LPT1", "\\ServerName\PrinterName" “God made everything out of nothing, but the nothingness shows through” ~ Paul Valery Related: Printer, add printer - WshNetwork.AddPrinterConnection printcon.vbs - change a Print connection to a different Queue/Server. NET VIEW - to view a list of printers. NET PRINT - View and Delete print jobs. PRNCNFG - Display, configure or rename a printer. PRNDRVR - Add, delete or list printer drivers. PRNMNGR - Add, delete, or list printers / connections, set the default printer. Network Printing - Advice & Tips.

WshNetwork.EnumPrinterConnections

Enumerate printer connections. Syntax myObject.EnumPrinterConnections Example Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oPrinters.Count - 1 Step 2 WScript.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1) Next ”Utility is when you have one telephone, luxury is when you have two, opulence is when you have three — and paradise is when you have none” ~ Doug Larson (English middle-distance runner) Related: Printer, set default printer - WshNetwork.SetDefaultPrinter Printer, remove printer - WshNetwork.RemovePrinterConnection Equivalent Windows CMD command: NET VIEW - to view a list of printers. Equivalent PowerShell cmdlet: GCIM -ClassName "Win32_Printer" -comp $strComputer

WshNetwork.SetDefaultPrinter

Assign a remote printer the role Default Printer. Syntax WshNetwork.SetDefaultPrinter(strPrinterName) Arguments strPrinterName : The remote printer's UNC name. Examples 'Set the Default Printer to \\research\library1 Dim WshNetwork Set WshNetwork = CreateObject("WScript.Network") WshNetwork.SetDefaultPrinter "\\research\library1" ' Connect to \\research\library1 and set it as the default. Set PrinterPath = "\\research\library1" Set WshNetwork = WScript.CreateObject("WScript.Network") Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath) If Not rc then WScript.Echo("Printer Connection Failed!") End If WshNetwork.SetDefaultPrinter PrinterPath This method fails when using a DOS-based printer connection. You cannot use the SetDefaultPrinter method find out the name of the current default printer. “People think that being famous is just about having your picture taken all the time and being rich rich rich, and you know what?... They're absolutely right” ~ Madonna Related: Printer, add printer - WshNetwork.AddPrinterConnection Printer, add Network printer - WshNetwork.AddWindowsPrinterConnection PRNMNGR - Add, delete, list printers and printer connections.

.RemovePrinterConnection

Remove a shared network printer connection. Syntax objNetwork.RemovePrinterConnection(strName, [bForce], [bUpdateProfile]) Key objNetwork : A WScript.network object strName : The printer name. It can be a UNC name, or a local name (such as LPT1). bForce : Force the removal of the mapped printer. (Boolean Optional, default = false). bUpdateProfile : Save changes in the user's profile (Boolean Optional, default = false) Example ' Disconnect a network printer Set PrinterPath = "\\printserv\MyPrinter" Set objNetwork = WScript.CreateObject("WScript.Network") objNetwork.RemovePrinterConnection (PrinterPath, true, true) The RemovePrinterConnection method removes both Windows and MS-DOS based printer connections. If the printer was connected using the method AddPrinterConnection, strName must be the printer's local name. If the printer was connected using the AddWindowsPrinterConnection method, or was added manually (using the Add Printer wizard), then strName must be the printer's UNC name. “Law: Once you eliminate your #1 problem, #2 gets a promotion” ~ Gerald Weinberg, "The Secrets of Consulting" Related: Printer, add printer - .AddPrinterConnection Printer, add Network printer - .AddWindowsPrinterConnection Printer, list printers - .EnumPrinterConnections Printer, set default printer - .SetDefaultPrinter PRNMNGR - Add, delete, list printers and printer connections.

Dim

Explicitly declare a new variable or array variable. Syntax Dim Varname[([subscript])] [,Varname[([subscript])] ...] Key Varname Name for the new variable. subscript For an array variable, the maximum number of array elements. This is zero based so 4 will create a variable with 5 elements, and 0 will create an array with 1 element. Dim statements are not required unless the VBScript contains an Option Explicit statement. Unlike many other languages there is no need to specify a data type (integer, string, object etc) All VBScript variables are variants. You can choose a variable name that indicates the data type to be stored e.g. strEmployee, but this is not enforced. Examples Option explicit Dim myString, price myString="Hello world" price=123 Create an Array Variable with 3 elements: Dim strPrintQueues(2) strPrintQueues(0)="HP Deskjet 1200" strPrintQueues(1)="Kyocera first floor" strPrintQueues(2)="Mikes printer" “Listen to many, speak to a few” ~ William Shakespeare Related: Array - Add values to an Array variable. Private VarName - Declare a local variable/array variable. Public VarName - Declare a public variable/array variable. Equivalent PowerShell cmdlet: $MyVariable = SomeValue

WScript.Quit

Exit the VBScript script. Syntax WScript.Quit [intErrorCode] Arguments: intErrorCode An exit (or error) code The default is to return no value (0) Quit is a wscript method. Example WScript.Quit 1 If calling a VBScript from a batch file, catch the Errorlevel with an IF statement cscript.exe MyScript.vbs IF errorlevel 1 goto s_next “You might as well aim high. Why shoot yourself in the foot when you can shoot yourself in the head?” - William Shatner Related Exit - Exit a subroutine. Equivalent Windows CMD command: EXIT - Quit the CMD shell Equivalent PowerShell cmdlet: Exit

.StdOut.ReadLine

Obtain User Input from the command prompt or retrieve (screen scrape) text from the output of a program. Syntax .StdOut.ReadLine() Examples ' Read a single line into a variable Dim strMyName WScript.StdOut.Write("Enter Your full Name>") WScript.StdIn.Read(0) strMyName = WScript.StdIn.ReadLine() WScript.StdOut.Write(strMyName) ' Read program output into a variable line by line Dim ObjExec Dim strFromProc Set objShell = WScript.CreateObject("WScript.Shell") Set ObjExec = objShell.Exec("cmd.exe /c dir") Do strFromProc = ObjExec.StdOut.ReadLine() WScript.Echo "ABC " & strFromProc & " DEF" Loop While Not ObjExec.Stdout.atEndOfStream “The unexamined life is not worth living” ~ Socrates Related: InputBox - Prompt for user input. .StdOut.Write - Text output. Equivalent PowerShell cmdlet: Read-Host - Read a line of input from the host console.

ReDim

Resize a dynamic array. Syntax ReDim [Preserve] varname(subscripts)[,varname(subscripts)]... Key Preserve Preserve existing data in the array where possible varname The name of the array variable subscripts The upper bound of the array dimension(s) comma separated if more than one. Example redim strPrintQueues(50) “Physical fitness is not only one of the most important keys to a healthy body, it is the basis of dynamic and creative intellectual activity” ~ John Fitzgerald Kennedy Related: Dim - Declare a new variable or array variable. Array - Add values to an Array variable. Equivalent in PowerShell: Not required, arrays are resized automatically.

.RegDelete

Delete a value from the Registry. Syntax objShell.RegDelete "strRegName" Arguments: objShell A WScript.Shell object strRegName : To delete a key instead of a value terminate strRegName with a backslash character \ strRegName must start with one of HKEY_CURRENT_USER or HKCU HKEY_USERS HKEY_LOCAL_MACHINE or HKLM HKEY_CLASSES_ROOT or HKCR HKEY_CURRENT_CONFIG Example Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.RegDelete "HKCU\Control Panel\Desktop\MyValue" objShell.RegDelete "HKCU\Control Panel\Desktop\MyKey\" Delete SubKeys in order objShell.RegDelete ("HKCU\Control Panel\Desktop\MyKey\MySubKey\"); objShell.RegDelete ("HKCU\Control Panel\Desktop\MyKey\"); “The way to love anything is to realize it might be lost” ~ G. K. Chesterton Related: Registry, read - .RegRead Registry, write - .RegWrite Equivalent Windows CMD command: REG - Read, Set or Delete registry keys and values. Equivalent PowerShell cmdlet: Remove-Item

.RegRead

Read a value from the Registry Syntax strValue = objShell.RegRead(strRegistryKey\) strValue = objShell.RegRead(strRegistryValue) Key objShell A WScript.Shell object The Registry key or value must start with one of: HKEY_CURRENT_USER or HKCU HKEY_USERS HKEY_LOCAL_MACHINE or HKLM HKEY_CLASSES_ROOT or HKCR HKEY_CURRENT_CONFIG Examples Dim objShell,strLogonServer,strDNSdomain strLogonServer = "HKEY_CURRENT_USER\Volatile Environment\LOGONSERVER" strDNSdomain = "HKEY_CURRENT_USER\Volatile Environment\USERDNSDOMAIN" Set objShell = WScript.CreateObject("WScript.Shell") WScript.Echo "Logon server: " objShell.RegRead(strLogonServer) WScript.Echo "DNS domain: " objShell.RegRead(strDNSdomain) “Machines can only find what ignorant men have programmed them to find” ~ Poul Anderson Related: Registry, delete - .RegDelete Registry, write - .RegWrite Equivalent Windows CMD command: REG - Read, Set or Delete registry keys and values. Equivalent PowerShell cmdlet: Get-Item

.RegWrite

Write a value to the Registry Syntax objShell.RegWrite strRegName, anyValue, [strType] Arguments: objShell A WScript.Shell object strRegName To set a key instead of a value terminate strRegName with a backslash character \ strRegName must start with one of HKEY_CURRENT_USER or HKCU HKEY_USERS HKEY_LOCAL_MACHINE or HKLM HKEY_CLASSES_ROOT or HKCR HKEY_CURRENT_CONFIG strType The data type, one of: REG_SZ, REG_EXPAND_SZ, (String values) REG_DWORD (convert to Integer value) REG_BINARY (Integer value) When you specify a key-name (as opposed to a value-name), RegRead returns the default value. Examples Set the registry flag to display Hidden and System files in Windows Explorer: Set WshShell = CreateObject("WScript.Shell") myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden" WshShell.RegWrite myKey,1,"REG_DWORD" Set the registry flag to hide Hidden and System files in Windows Explorer (the default) Set WshShell = CreateObject("WScript.Shell") myKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden" WshShell.RegWrite myKey,0,"REG_DWORD" Create a "default value" at HKCU\KeyName\ n.b. the trailing backslash is required: SetWshShell=WScript.CreateObject("WScript.Shell") WshShell.RegWrite"HKCU\KeyName\","","REG_SZ" “Nothing is permanent” - Buddha Related: Registry, delete - WshShell.RegDelete Registry, read - WshShell.RegRead Q281309 - Unable to Use a "\" in a Key Name with RegWrite. Equivalent Windows CMD command: REG - Read, Set or Delete registry keys and values. Equivalent PowerShell cmdlet: Set-Item

REM

Include explanatory remarks in a VBScript program. Syntax ' comment command ' comment REM comment command : REM comment If a REM statement is added on the same line as a command, then it must be prefixed with a colon (the end-of-line statement). This is not required when using the apostrophe comment prefix. Examples Dim MyStr1, MyStr2 MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed. #Now stand in the place where you work, Now face West Think about the place where you live, Wonder why you haven't before# ~ REM 'Stand' Related: Echo - Echo text to screen.

Replace

Find and replace text in a string. Syntax Replace(String, StringToFind, ReplaceString [,Start [,Count [, Compare]]]) Key String The initial string of Text StringToFind The text we want to find in String ReplaceString The string that will replace StringToFind if a match is found Start Character position in string at which to start the search Count The number of replacements to perform Compare Either vbBinaryCompare or VBTextCompare If ReplaceString ="" then the StringToFind will be deleted from String. Example myString="Hello John" myString=Replace(myString,"John","world") WScript.Echo myString “Reputations are made by searching for things that can't be done and doing them” ~ Frank Tyger Related: replace.vbs - Script to search and replace text. InStr - Find one string within another. RegExp - Regular expression search object. StrComp - Compare two strings. Equivalent in PowerShell: $result = "Hello Cleveland" -replace("Cleveland","world")

RGB

Return a whole number representing an RGB colour value. Syntax Rgb(Red,Green,Blue) Key Red Number in the range 0-255 representing the red component of the color. Green Number in the range 0-255 representing the green component of the color. Blue Number in the range 0-255 representing the blue component of the color. For any argument, numeric values over 255 are assumed to be 255. Example Dim intColR, intColG, intColB intColR = 255 intColG = 0 intColB = 0 WScript.Echo RGB(intColR, intColG, intColB) “Therefore in 1909 I announced one morning, without any previous warning, that in the future we were going to build only one model, that the model was going to be "Model T," and that the chassis would be exactly the same for all cars, and I remarked: Any customer can have a car painted any colour that he wants so long as it is black” ~ Henry Ford Related: GetLocale - Return the Regional LocaleID.

Right

Extract a substring from a string, starting from the right-most character. Syntax Right(string, NumberOfCharacters) Key string A string or string expression. NumberOfCharacters The Number of characters to return Examples Dim strDemo strDemo = Right("The world is everlasting", 11 ) Msgbox strDemo Returns: "everlasting" A function to pad out a value with leading zeros: Function LPad(strValue, intLength) LPad = Right("00" & strValue, intLength) End Function mydemo=LPad(4 2) wscript.echo mydemo Returns: 04 “Begin at the beginning, the King said, very gravely, and go on till you come to the end: then stop” ~ Lewis Carroll Related: Left - Extract a substring from a string. Mid - Extract a substring from a string.

Rnd

Return a pseudorandom number. Syntax Rnd[(seed)] Key seed A seed value of 0 will return the most recent random number A seed value > 0 will return the next random number(default) A seed value < 0 will return the same number Example myrand = rnd() WScript.Echo myrand “Find the seed at the bottom of your heart and bring forth a flower” ~ Shigenori Kameoka Related: Randomize - Initialise the random number generator. Equivalent PowerShell cmdlet: Get-Random Random Numbers in CMD or .js

Round

Round a number to n decimal places. Syntax Round(Expression [, NumDecimalPlaces )]) Key Expression A Numeric expression NumDecimalPlaces Decimal places to keep 1=> 12.1 3=> 12.123 Example myNum=123.4567 myNewNum=Round(myNum,2) WScript.Echo myNewNum “One tequila, two tequila, three tequila, floor” ~ George Carlins Related: Int(number) - Return the integer portion of a number. Equivalent in PowerShell: $result = [math]::round(123.4567, 2)

Rtrim

Remove trailing spaces from a string. Syntax Rtrim(string) Key string A text string or string expression. Examples Dim strDemo strDemo = Rtrim("The world is everlasting ") Returns "The world is everlasting" “The hands of every clock are shears, trimming us away scrap by scrap, and every time piece with a digital readout blinks us towards implosion” ~ Dean Koontz Related: Right - Extract a substring from a string. LTrim - Remove leading spaces from a string. Trim - Remove leading and trailing spaces from a string.

.Run

Run an external Command. Syntax objShell.Run (strCommand, [intWindowStyle], [bWaitOnReturn]) Key objShell : A WScript.Shell object strCommand : The Command to be executed intWindowStyle (Optional) : Int value indicating the appearance of the program's window. Not all programs make use of this. bWaitOnReturn : Wait for the command to complete before continuing execution of the wsh script. If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application. If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination (and returns an error code of 0) Specifying the bWaitOnReturn parameter allows you to run programs synchronously (one at a time). Environment variables within the argument strCommand are automatically expanded. If a file type has been properly registered to a particular program, calling run on a file of that type executes the program. For example, if Word is installed on your computer system, calling Run on a *.doc file starts Word, and loads the document. Settings for intWindowStyle:
0 Hide the window (and activate another window.) 1 Activate and display the window. (restore size and position) Specify this flag when displaying a window for the first time. 2 Activate & minimize. 3 Activate & maximize. 4 Restore. The active window remains active. 5 Activate & Restore. 6 Minimize & activate the next top-level window in the Z order. 7 Minimize. The active window remains active. 8 Display the window in its current state. The active window remains active. 9 Restore & Activate. Specify this flag when restoring a minimized window. 10 Sets the show-state based on the state of the program that started the application.

Invisible.vbs

In the Windows Task Scheduler the task properties include a tick box for "Hidden", this does not minify or hide the command window, but does hide the task from Task Scheduler's list of tasks. (The menu View > Show hidden tasks is by default ticked.) This one line VBScript can be used to run a command in an invisible window: CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False An example running 'Demo.cmd' with invisible.vbs wscript.exe "invisible.vbs" "demo.cmd" //nologo If running this as a scheduled task, either provide the full path to the VBS and Batch file, or set the 'Start In' folder when creating the task. If you also need to pass parameters to the batch file, then use this version of invisible.vbs which passes them along (source Pyprohly): Dim Args() ReDim Args(WScript.Arguments.Count - 1) For i = 0 To WScript.Arguments.Count - 1 Args(i) = """" & WScript.Arguments(i) & """" Next CreateObject("WScript.Shell").Run Join(Args), 0, False

Minimized.vbs

This one line VBScript can be used to run a command in a minimized window: CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 7, False An example running 'Demo.cmd' with minimized.vbs %SystemRoot%\system32\wscript.exe "minimized.vbs" "demo.cmd" //nologo
Examples Launch Notepad with the current executed script: Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run ("%windir%\notepad.exe " & WScript.ScriptFullName) Launch Notepad with the current executed script, specify the window type, wait for Notepad to be shut down by the user, and save the error code returned from Notepad when it exits: Set objShell = WScript.CreateObject("WScript.Shell") intReturn = objShell.Run("notepad.exe " & WScript.ScriptFullName, 1, true) If intReturn <> 0 Then Wscript.Echo "Error running program" End If Open a cmd window, change the path to C:\ , and execute the DIR command: Dim objShell Set objShell = WScript.CreateObject ("WScript.shell") objShell.run "cmd /K CD C:\ & Dir" Set objShell = Nothing Call one VB script from another. This can be done as shown below, although it is usually better to put everything in a single script and use Functions to split up the blocks of code. Set objShell = CreateObject("WScript.Shell") objShell.run("cscript C:\scripts\demo.vbs") “Tell the truth and run” ~ Yugoslavian proverb Related: .Exec - Execute command, returning an object. .ShellExecute - Run an application in the Windows Shell. cscript - Run a VB Script .vbs file Arguments - Passing arguments to a script. Equivalent Windows CMD command: START - Start a program or command. Equivalent PowerShell cmdlet: Run

Second

Return the seconds of the minute (a number from 0 to 59) for a given time value. Syntax Second(time_value) Key time_value A valid time. Examples Dim intDemo intDemo = Second(dtmShiftEnd) intDemo = Second(#08:55:30 AM#) “For a moment, nothing happened. Then, after a second or so, nothing continued to happen” ~ Douglas Adams Related: Day - Return the day of the month. Minute - Return the minute of the hour. Hour - Return the hour of the day.

Select ... Case

Conditionally execute a block of statements. Syntax Select Case TestExpression [Case ExpressionList [Statements-n]]... [Case Else [ElseStatements]] End Select Key TestExpression A numeric or String expression which will determine which block of code is executed ExpressionList Comma delimited list of expressions to compare/ match against TestExpression Statements-n Statements to execute if a match is found. ElseStatements Statements to execute if a match is not found. Example strPerson="Jasper" select case strPerson case "Alex" WScript.Echo "We found Alex" case "Jasper" WScript.Echo "We found Jasper" case "Helen" WScript.Echo "We found Helen" end select “The day soldiers stop bringing you their problems is the day you have stopped leading them. They have either lost confidence that you can help them or concluded that you do not care. Either case is a failure of leadership” ~ Colin Powell Related: If..Then - Conditionally execute a block of statements. While...Wend - Conditionally repeat a block of statements. Equivalent in PowerShell: Switch - Multiple if statements.

WshShell.SendKeys

Send one or more keystrokes to the active window as if they were typed at the keyboard. This method is similar to the VB SendKeys method. WshShell.SendKeys "Character_string_and/or_SendKeys" Most ASCII characters can be represented by the character itself. E.g, the key sequence FRED can be represented by "FRED". Some special keys, such as the control keys, function keys etc are encoded in a string enclosed by {braces} See the table below
Key/Character SendKey Description
~ {~} Send a tilde (~)
! {!} Send an exclamation point (!)
^ {^} Send a caret (^)
+ {+} Send a plus sign (+)
Backspace {BACKSPACE} or {BKSP} or {BS} Send a Backspace keystroke
Break {BREAK} Send a Break keystroke
Caps Lock {CAPSLOCK} Press the Caps Lock Key (toggle on or off)
Clear {CLEAR} Clear the field
Delete {DELETE} or {DEL} Send a Delete keystroke
Insert {INSERT} or {INS} Send an Insert keystroke
Cursor control arrows {LEFT} / {RIGHT} / {UP} / {DOWN} Send a Left/Right/Up/Down Arrow
End {END} Send an End keystroke
Enter {ENTER} or ~ Send an Enter keystroke
Escape {ESCAPE} Send an Esc keystroke
F1 through F16 {F1} through {F16} Send a Function keystroke
Help {HELP} Send a Help keystroke
Home {HOME} Send a Home keystroke
Numlock {NUMLOCK} Send a Num Lock keystroke
Page Down Page Up {PGDN} {PGUP} Send a Page Down or Page Up keystroke
Print Screen {PRTSC} Send a Print Screen keystroke
Scroll lock {SCROLLLOCK} Press the Scroll lock Key (toggle on or off)
TAB {TAB} Send a TAB keystroke
To specify keys combined with any combination of SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following: For SHIFT prefix with + For CTRL prefix with ^ For ALT prefix with % Example ' Open notepad Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "notepad.exe", 9 ' Give Notepad time to load WScript.Sleep 500 ' Type in Hello World WshShell.SendKeys "Hello World!" WshShell.SendKeys "{ENTER}" ' Add the date WshShell.SendKeys "{F5}" “History repeats itself; that's one of the things that's wrong with history” ~ Clarence Darrow Related: TechNet - SendKeys Method. CLIP - Copy STDIN to the Windows clipboard. Install a Font remotely with VBS - Microsoft Script Center. Equivalent PowerShell: none but VBScript Sendkeys can be called using New-Object

Set

Assign an object reference. Syntax Set variable = object The variable name, can be anything but typically will start with obj to indicate it is a programmable object with properties and methods.
Methods can be run against the object variable using the syntax objSomething.methodName Properties can be accessed by assigning a variable: varValue = objSomething.propertyX
Unless you are using ADO objects that have to be explicitly cleaned up in the right order before they go out of scope, it is not necessary to assign object to nothing at the end of your scripts Example Set objWshController = WScript.CreateObject("WshController") “We can make good tests run fast but we can't make fast tests be good” - Ryan Tomayko Related: Dim - Declare a new variable or array variable. VB Script Constants and Variables Set Objects To Nothing? - Eric Lippert.

SetLocale

Set the value of the local computers LocaleID. Syntax SetLocale(LocaleID) Key LocaleID Decimal or String literal indicating the country. Examples 'Set locale to the UK SetLocale("en-gb") 'Set locale to Germany SetLocale("de") “Who looks outside, dreams; who looks inside, awakes” ~ Carl Gustav Jung Related: GetLocale - Return the Regional LocaleID

Windows Locales

A locale is neither a language nor a country, the same language may be spoken in multiple countries (often with subtle differences) and a single country may speak multiple languages. A locale is therefore an area where a particular language is spoken which may (or may not) align with geographical and/or political boundaries. A locale also includes regional standards for date and time formatting, for example French-Canadians use a different date format to English-Canadians and both of those are different to the date format used in France. In multi-lingual countries it is common for the same user to switch between languages many times a day. In Windows CMD, to retrieve the current locale (short code) use: For /f "tokens=3" %%G in ('Reg query "HKCU\Control Panel\International" /v LocaleName') Do Set _locale=%%G Echo %_Locale% In PowerShell: PS C:\> (Get-WinSystemLocale).Name Locale short codes are based on ISO 639-1 language codes with an ISO 3166 country code appended as needed.
Locale description Short string Hexadecimal value Decimal value Start of Week blank=Monday (ISO default)
Afar aa 0x1000 4096 Sunday
Afar (Djibouti) aa-DJ 0x1000 4096 Saturday
Afar (Eritrea) aa-ER 0x1000 4096
Afar (Ethiopia) aa-ET 0x1000 4096 Sunday
Afrikaans af 0x36 54 Sunday
Afrikaans (Namibia) af-NA 0x1000 4096
Afrikaans (South Africa) af-ZA 0x436 1078 Sunday
Aghem agq 0x1000 4096
Aghem (Cameroon) agq-CM 0x1000 4096
Akan ak 0x1000 4096
Akan (Ghana) ak-GH 0x1000 4096
Albanian sq 0x1C 28
Albanian (Albania) sq-AL 0x41C 1052
Albanian (Kosovo) sq-XK 0x1000 4096
Albanian (Macedonia, FYRO) sq-MK 0x1000 4096
Alsatian gsw 0x84 132
Alsatian (France) gsw-FR 0x484 1156
Alsatian (Liechtenstein) gsw-LI 0x1000 4096
Alsatian (Switzerland) gsw-CH 0x1000 4096
Amharic am 0x5E 94 Sunday
Amharic (Ethiopia) am-ET 0x45E 1118 Sunday
Arabic ar 0x1 1 Sunday
Arabic (Algeria) ar-DZ 0x1401 5121 Saturday
Arabic (Bahrain) ar-BH 0x3C01 15361 Saturday
Arabic (Chad) ar-TD 0x1000 4096
Arabic (Comoros) ar-KM 0x1000 4096
Arabic (Djibouti) ar-DJ 0x1000 4096 Saturday
Arabic (Egypt) ar-EG 0xC01 3073 Saturday
Arabic (Eritrea) ar-ER 0x1000 4096
Arabic (Iraq) ar-IQ 0x801 2049 Saturday
Arabic (Israel) ar-IL 0x1000 4096 Sunday
Arabic (Jordan) ar-JO 0x2C01 11265 Saturday
Arabic (Kuwait) ar-KW 0x3401 13313 Saturday
Arabic (Lebanon) ar-LB 0x3001 12289
Arabic (Libya) ar-LY 0x1001 4097 Saturday
Arabic (Mauritania) ar-MR 0x1000 4096
Arabic (Morocco) ar-MA 0x1801 6145
Arabic (Oman) ar-OM 0x2001 8193 Sunday
Arabic (Palestinian Authority) ar-PS 0x1000 4096
Arabic (Qatar) ar-QA 0x4001 16385 Saturday
Arabic (Saudi Arabia) ar-SA 0x401 1025 Sunday
Arabic (Somalia) ar-SO 0x1000 4096
Arabic (South Sudan) ar-SS 0x1000 4096
Arabic (Sudan) ar-SD 0x1000 4096 Saturday
Arabic (Syria) ar-SY 0x2801 10241 Saturday
Arabic (Tunisia) ar-TN 0x1C01 7169
Arabic (U.A.E.) ar-AE 0x3801 14337 Saturday
Arabic (World) ar-001 0x1000 4096
Arabic (Yemen) ar-YE 0x2401 9217 Saturday
Armenian hy 0x2B 43
Armenian (Armenia) hy-AM 0x42B 1067
Assamese as 0x4D 77
Assamese (India) as-IN 0x44D 1101
Asturian ast 0x1000 4096
Asturian (Spain) ast-ES 0x1000 4096
Asu asa 0x1000 4096
Asu (Tanzania) asa-TZ 0x1000 4096
Azerbaijani az 0x2C 44
Azerbaijani (Cyrillic) az-Cyrl 0x742C 29740
Azerbaijani (Cyrillic, Azerbaijan) az-Cyrl-AZ 0x82C 2092
Azerbaijani (Latin) az-Latn 0x782C 30764
Azerbaijani (Latin, Azerbaijan) az-Latn-AZ 0x42C 1068
Bafia ksf 0x1000 4096
Bafia (Cameroon) ksf-CM 0x1000 4096
Bambara bm 0x1000 4096
Bambara (Latin) bm-Latn 0x1000 4096
Bambara (Latin, Mali) bm-Latn-ML 0x1000 4096
Bangla bn 0x45 69 Sunday
Bangla (Bangladesh) bn-BD 0x845 2117 Sunday
Bangla (India) bn-IN 0x445 1093
Basaa bas 0x1000 4096
Basaa (Cameroon) bas-CM 0x1000 4096
Bashkir ba 0x6D 109
Bashkir (Russia) ba-RU 0x46D 1133
Basque eu 0x2D 45
Basque (Basque) eu-ES 0x42D 1069
Belarusian be 0x23 35
Belarusian (Belarus) be-BY 0x423 1059
Bemba bem 0x1000 4096
Bemba (Zambia) bem-ZM 0x1000 4096
Bena bez 0x1000 4096
Bena (Tanzania) bez-TZ 0x1000 4096
Blin byn 0x1000 4096
Blin (Eritrea) byn-ER 0x1000 4096
Bodo brx 0x1000 4096 Sunday
Bodo (India) brx-IN 0x1000 4096 Sunday
Bosnian bs 0x781A 30746
Bosnian (Cyrillic) bs-Cyrl 0x641A 25626
Bosnian (Cyrillic, Bosnia and Herzegovina) bs-Cyrl-BA 0x201A 8218
Bosnian (Latin) bs-Latn 0x681A 26650
Bosnian (Latin, Bosnia and Herzegovina) bs-Latn-BA 0x141A 5146
Breton br 0x7E 126
Breton (France) br-FR 0x47E 1150
Bulgarian bg 0x2 2
Bulgarian (Bulgaria) bg-BG 0x402 1026
Burmese my 0x55 85 Sunday
Burmese (Myanmar) my-MM 0x455 1109 Sunday
Catalan ca 0x3 3
Catalan (Andorra) ca-AD 0x1000 4096
Catalan (Catalan) ca-ES 0x403 1027
Catalan (France) ca-FR 0x1000 4096
Catalan (Italy) ca-IT 0x1000 4096
Central Atlas Tamazight (Arabic) tzm-Arab 0x1000 4096 Saturday
Central Atlas Tamazight (Arabic, Morocco) tzm-Arab-MA 0x45F 1119 Saturday
Central Atlas Tamazight (Latin, Morocco) tzm-Latn-MA 0x1000 4096 Saturday
Central Atlas Tamazight (Tifinagh, Morocco) tzm-Tfng-MA 0x105F 4191 Saturday
Central Kurdish ku 0x92 146 Sunday
Central Kurdish (Arabic) ku-Arab 0x7C92 31890
Central Kurdish (Iraq) ku-Arab-IQ 0x492 1170 Sunday
Chechen ce 0x1000 4096
Chechen (Russia) ce-RU 0x1000 4096
Cherokee chr 0x5C 92 Sunday
Cherokee (Cherokee) chr-Cher-US 0x45C 1116 Sunday
Cherokee (Cherokee) chr-Cher 0x7C5C 31836 Sunday
Chiga cgg 0x1000 4096
Chiga (Uganda) cgg-UG 0x1000 4096
Chinese zh 0x7804 30724
Chinese (Simplified Han, Hong Kong SAR) zh-Hans-HK 0x1000 4096 Sunday
Chinese (Simplified Han, Macao SAR) zh-Hans-MO 0x1000 4096 Sunday
Chinese (Simplified) zh-Hans 0x4 4
Chinese (Simplified) Legacy zh-Hans 0x4 4
Chinese (Simplified, PRC) zh-CN 0x804 2052
Chinese (Simplified, Singapore) zh-SG 0x1004 4100 Sunday
Chinese (Traditional) zh-Hant 0x7C04 31748 Sunday
Chinese (Traditional) Legacy zh-Hant 0x7C04 31748 Sunday
Chinese (Traditional, Hong Kong S.A.R.) zh-HK 0xC04 3076 Sunday
Chinese (Traditional, Macao S.A.R.) zh-MO 0x1404 5124 Sunday
Chinese (Traditional, Taiwan) zh-TW 0x404 1028 Sunday
Church Slavic cu 0x1000 4096
Church Slavic (Russia) cu-RU 0x1000 4096
Colognian ksh 0x1000 4096
Cornish kw 0x1000 4096
Cornish (United Kingdom) kw-GB 0x1000 4096
Corsican co 0x83 131
Corsican (France) co-FR 0x483 1155
Croatian hr 0x1A 26
Croatian (Croatia) hr-HR 0x41A 1050
Croatian (Latin, Bosnia and Herzegovina) hr-BA 0x101A 4122
Czech cs 0x5 5
Czech (Czech Republic) cs-CZ 0x405 1029
Danish da 0x6 6
Danish (Denmark) da-DK 0x406 1030
Danish (Greenland) da-GL 0x1000 4096
Dari prs 0x8C 140 Saturday
Dari (Afghanistan) prs-AF 0x48C 1164 Saturday
Divehi dv 0x65 101 Sunday
Divehi (Maldives) dv-MV 0x465 1125 Sunday
Duala dua 0x1000 4096
Duala (Cameroon) dua-CM 0x1000 4096
Dutch nl 0x13 19
Dutch (Aruba) nl-AW 0x1000 4096
Dutch (Belgium) nl-BE 0x813 2067
Dutch (Bonaire, Sint Eustatius and Saba) nl-BQ 0x1000 4096
Dutch (Curaao) nl-CW 0x1000 4096
Dutch (Netherlands) nl-NL 0x413 1043
Dutch (Sint Maarten) nl-SX 0x1000 4096
Dutch (Suriname) nl-SR 0x1000 4096
Dzongkha dz 0x1000 4096 Sunday
Dzongkha (Bhutan) dz-BT 0xC51 3153 Sunday
Edo bin 0x66 102 Sunday
Edo (Nigeria) bin-NG 0x466 1126 Sunday
Embu ebu 0x1000 4096 Sunday
Embu (Kenya) ebu-KE 0x1000 4096 Sunday
English en 0x9 9
English (American Samoa) en-AS 0x1000 4096 Sunday
English (Anguilla) en-AI 0x1000 4096
English (Antigua and Barbuda) en-AG 0x1000 4096 Sunday
English (Australia) en-AU 0xC09 3081
English (Austria) en-AT 0x1000 4096
English (Bahamas) en-BS 0x1000 4096 Sunday
English (Barbados) en-BB 0x1000 4096
English (Belgium) en-BE 0x1000 4096
English (Belize) en-BZ 0x2809 10249 Sunday
English (Bermuda) en-BM 0x1000 4096
English (Botswana) en-BW 0x1000 4096 Sunday
English (British Indian Ocean Territory) en-IO 0x1000 4096
English (British Virgin Islands) en-VG 0x1000 4096
English (Burundi) en-BI 0x1000 4096
English (Cameroon) en-CM 0x1000 4096
English (Canada) en-CA 0x1009 4105 Sunday
English (Caribbean) en-029 0x2409 9225
English (Cayman Islands) en-KY 0x1000 4096
English (Christmas Island) en-CX 0x1000 4096
English (Cocos [Keeling] Islands) en-CC 0x1000 4096
English (Cook Islands) en-CK 0x1000 4096
English (Cyprus) en-CY 0x1000 4096
English (Denmark) en-DK 0x1000 4096
English (Dominica) en-DM 0x1000 4096 Sunday
English (Eritrea) en-ER 0x1000 4096
English (Europe) en-150 0x1000 4096
English (Falkland Islands) en-FK 0x1000 4096
English (Fiji) en-FJ 0x1000 4096
English (Finland) en-FI 0x1000 4096
English (Gambia) en-GM 0x1000 4096
English (Germany) en-DE 0x1000 4096
English (Ghana) en-GH 0x1000 4096
English (Gibraltar) en-GI 0x1000 4096
English (Grenada) en-GD 0x1000 4096
English (Guam) en-GU 0x1000 4096 Sunday
English (Guernsey) en-GG 0x1000 4096
English (Guyana) en-GY 0x1000 4096
English (Hong Kong SAR) en-HK 0x3C09 15369 Sunday
English (India) en-IN 0x4009 16393
English (Indonesia) en-ID 0x3809 14345 Sunday
English (Ireland) en-IE 0x1809 6153 Sunday
English (Isle of Man) en-IM 0x1000 4096
English (Israel) en-IL 0x1000 4096
English (Jamaica) en-JM 0x2009 8201 Sunday
English (Jersey) en-JE 0x1000 4096
English (Kenya) en-KE 0x1000 4096 Sunday
English (Kiribati) en-KI 0x1000 4096
English (Lesotho) en-LS 0x1000 4096
English (Liberia) en-LR 0x1000 4096
English (Macao SAR) en-MO 0x1000 4096 Sunday
English (Madagascar) en-MG 0x1000 4096
English (Malawi) en-MW 0x1000 4096
English (Malaysia) en-MY 0x4409 17417 Sunday
English (Malta) en-MT 0x1000 4096 Sunday
English (Marshall Islands) en-MH 0x1000 4096 Sunday
English (Mauritius) en-MU 0x1000 4096
English (Micronesia) en-FM 0x1000 4096
English (Montserrat) en-MS 0x1000 4096
English (Namibia) en-NA 0x1000 4096
English (Nauru) en-NR 0x1000 4096
English (Netherlands) en-NL 0x1000 4096
English (New Zealand) en-NZ 0x1409 5129 Sunday
English (Nigeria) en-NG 0x1000 4096
English (Niue) en-NU 0x1000 4096
English (Norfolk Island) en-NF 0x1000 4096
English (Northern Mariana Islands) en-MP 0x1000 4096
English (Pakistan) en-PK 0x1000 4096 Sunday
English (Palau) en-PW 0x1000 4096
English (Papua New Guinea) en-PG 0x1000 4096
English (Pitcairn Islands) en-PN 0x1000 4096
English (Puerto Rico) en-PR 0x1000 4096 Sunday
English (Philippines) en-PH 0x3409 13321 Sunday
English (Rwanda) en-RW 0x1000 4096
English (Saint Kitts and Nevis) en-KN 0x1000 4096
English (Saint Lucia) en-LC 0x1000 4096
English (Saint Vincent and the Grenadines) en-VC 0x1000 4096
English (Samoa) en-WS 0x1000 4096 Sunday
English (Seychelles) en-SC 0x1000 4096
English (Sierra Leone) en-SL 0x1000 4096
English (Singapore) en-SG 0x4809 18441 Sunday
English (Sint Maarten) en-SX 0x1000 4096
English (Slovenia) en-SI 0x1000 4096
English (Solomon Islands) en-SB 0x1000 4096
English (South Africa) en-ZA 0x1C09 7177 Sunday
English (South Sudan) en-SS 0x1000 4096
English (St Helena, Ascension, Tristan da Cunha) en-SH 0x1000 4096
English (Sudan) en-SD 0x1000 4096 Saturday
English (Swaziland) en-SZ 0x1000 4096
English (Sweden) en-SE 0x1000 4096
English (Switzerland) en-CH 0x1000 4096
English (Tanzania) en-TZ 0x1000 4096
English (Tokelau) en-TK 0x1000 4096
English (Tonga) en-TO 0x1000 4096
English (Trinidad and Tobago) en-TT 0x2C09 11273 Sunday
English (Turks and Caicos Islands) en-TC 0x1000 4096
English (Tuvalu) en-TV 0x1000 4096
English (Uganda) en-UG 0x1000 4096
English (United Kingdom) en-GB 0x809 2057
English (United States) en-US 0x409 1033 Sunday
English (US Minor Outlying Islands) en-UM 0x1000 4096 Sunday
English (US Virgin Islands) en-VI 0x1000 4096 Sunday
English (Vanuatu) en-VU 0x1000 4096
English (World) en-001 0x1000 4096
English (Zambia) en-ZM 0x1000 4096
English (Zimbabwe) en-ZW 0x3009 12297 Sunday
Esperanto eo 0x1000 4096
Esperanto (World) eo-001 0x1000 4096
Estonian et 0x25 37
Estonian (Estonia) et-EE 0x425 1061
Ewe ee 0x1000 4096
Ewe (Ghana) ee-GH 0x1000 4096
Ewe (Togo) ee-TG 0x1000 4096
Ewondo ewo 0x1000 4096
Ewondo (Cameroon) ewo-CM 0x1000 4096
Faroese fo 0x38 56
Faroese (Denmark) fo-DK 0x1000 4096
Faroese (Faroe Islands) fo-FO 0x438 1080
Filipino fil 0x64 100 Sunday
Filipino (Philippines) fil-PH 0x464 1124 Sunday
Finnish fi 0xB 11
Finnish (Finland) fi-FI 0x40B 1035
French fr 0xC 12
French (Algeria) fr-DZ 0x1000 4096 Saturday
French (Belgium) fr-BE 0x80C 2060
French (Benin) fr-BJ 0x1000 4096
French (Burkina Faso) fr-BF 0x1000 4096
French (Burundi) fr-BI 0x1000 4096
French (Cameroon) fr-CM 0x2C0C 11276
French (Canada) fr-CA 0xC0C 3084 Sunday
French (Caribbean) fr-029 0x1C0C 7180
French (Central African Republic) fr-CF 0x1000 4096
French (Chad) fr-TD 0x1000 4096
French (Comoros) fr-KM 0x1000 4096
French (Congo DRC) fr-CD 0x240C 9228
French (Congo) fr-CG 0x1000 4096
French (Cte d’Ivoire) fr-CI 0x300C 12300
French (Djibouti) fr-DJ 0x1000 4096 Saturday
French (Equatorial Guinea) fr-GQ 0x1000 4096
French (France) fr-FR 0x40C 1036
French (French Guiana) fr-GF 0x1000 4096
French (French Polynesia) fr-PF 0x1000 4096
French (Gabon) fr-GA 0x1000 4096
French (Guadeloupe) fr-GP 0x1000 4096
French (Guinea) fr-GN 0x1000 4096
French (Haiti) fr-HT 0x3C0C 15372
French (Luxembourg) fr-LU 0x140C 5132
French (Madagascar) fr-MG 0x1000 4096
French (Mali) fr-ML 0x340C 13324
French (Martinique) fr-MQ 0x1000 4096
French (Mauritania) fr-MR 0x1000 4096
French (Mauritius) fr-MU 0x1000 4096
French (Mayotte) fr-YT 0x1000 4096
French (Monaco) fr-MC 0x180C 6156
French (Morocco) fr-MA 0x380C 14348 Saturday
French (New Caledonia) fr-NC 0x1000 4096
French (Niger) fr-NE 0x1000 4096
French (Reunion) fr-RE 0x200C 8204
French (Rwanda) fr-RW 0x1000 4096
French (Saint Barthélemy) fr-BL 0x1000 4096
French (Saint Martin) fr-MF 0x1000 4096
French (Saint Pierre and Miquelon) fr-PM 0x1000 4096
French (Senegal) fr-SN 0x280C 10252
French (Seychelles) fr-SC 0x1000 4096
French (Switzerland) fr-CH 0x100C 4108
French (Syria) fr-SY 0x1000 4096 Saturday
French (Togo) fr-TG 0x1000 4096
French (Tunisia) fr-TN 0x1000 4096 Sunday
French (Vanuatu) fr-VU 0x1000 4096
French (Wallis and Futuna) fr-WF 0x1000 4096
Frisian fy 0x62 98
Frisian (Netherlands) fy-NL 0x462 1122
Friulian fur 0x1000 4096
Friulian (Italy) fur-IT 0x1000 4096
Fulah ff 0x67 103
Fulah (Cameroon) ff-CM 0x1000 4096
Fulah (Guinea) ff-GN 0x1000 4096
Fulah (Latin) ff-Latn 0x7C67 31847
Fulah (Latin, Senegal) ff-Latn-SN 0x867 2151
Fulah (Mauritania) ff-MR 0x1000 4096
Fulah (Nigeria) ff-NG 0x467 1127 Sunday
Galician gl 0x56 86
Galician (Galician) gl-ES 0x456 1110
Ganda lg 0x1000 4096
Ganda (Uganda) lg-UG 0x1000 4096
Georgian ka 0x37 55
Georgian (Georgia) ka-GE 0x437 1079
German de 0x7 7
German (Austria) de-AT 0xC07 3079
German (Belgium) de-BE 0x1000 4096
German (Germany) de-DE 0x407 1031
German (Italy) de-IT 0x1000 4096
German (Liechtenstein) de-LI 0x1407 5127
German (Luxembourg) de-LU 0x1007 4103
German (Switzerland) de-CH 0x807 2055
Greek el 0x8 8
Greek (Cyprus) el-CY 0x1000 4096
Greek (Greece) el-GR 0x408 1032
Greenlandic kl 0x6F 111
Greenlandic (Greenland) kl-GL 0x46F 1135
Guarani gn 0x74 116 Sunday
Guarani (Paraguay) gn-PY 0x474 1140 Sunday
Gujarati gu 0x47 71
Gujarati (India) gu-IN 0x447 1095
Gusii guz 0x1000 4096 Sunday
Gusii (Kenya) guz-KE 0x1000 4096 Sunday
Hausa ha 0x68 104
Hausa (Latin) ha-Latn 0x7C68 31848
Hausa (Latin, Ghana) ha-Latn-GH 0x1000 4096
Hausa (Latin, Niger) ha-Latn-NE 0x1000 4096
Hausa (Latin, Nigeria) ha-Latn-NG 0x468 1128
Hawaiian haw 0x75 117 Sunday
Hawaiian (United States) haw-US 0x475 1141 Sunday
Hebrew he 0xD 13 Sunday
Hebrew (Israel) he-IL 0x40D 1037 Sunday
Hindi hi 0x39 57
Hindi (India) hi-IN 0x439 1081
Hungarian hu 0xE 14
Hungarian (Hungary) hu-HU 0x40E 1038
Ibibio ibb 0x69 105 Sunday
Ibibio (Nigeria) ibb-NG 0x469 1129 Sunday
Icelandic is 0xF 15
Icelandic (Iceland) is-IS 0x40F 1039
Igbo ig 0x70 112
Igbo (Nigeria) ig-NG 0x470 1136
Indonesian id 0x21 33 Sunday
Indonesian (Indonesia) id-ID 0x421 1057 Sunday
Interlingua ia 0x1000 4096
Interlingua (France) ia-FR 0x1000 4096
Interlingua (World) ia-001 0x1000 4096
Inuktitut iu 0x5D 93 Sunday
Inuktitut (Latin) iu-Latn 0x7C5D 31837 Sunday
Inuktitut (Latin, Canada) iu-Latn-CA 0x85D 2141 Sunday
Inuktitut (Syllabics) iu-Cans 0x785D 30813 Sunday
Inuktitut (Syllabics, Canada) iu-Cans-CA 0x45D 1117 Sunday
Invariant Language (Invariant Country) 0x7F 127
Irish ga 0x3C 60 Sunday
Irish (Ireland) ga-IE 0x83C 2108 Sunday
isiXhosa xh 0x34 52 Sunday
isiXhosa (South Africa) xh-ZA 0x434 1076 Sunday
isiZulu zu 0x35 53 Sunday
isiZulu (South Africa) zu-ZA 0x435 1077 Sunday
Italian it 0x10 16
Italian (Italy) it-IT 0x410 1040
Italian (San Marino) it-SM 0x1000 4096
Italian (Switzerland) it-CH 0x810 2064
Italian (Vatican City) it-VA 0x1000 4096
Japanese ja 0x11 17 Sunday
Japanese (Japan) ja-JP 0x411 1041 Sunday
Javanese jv-Latn 0x1000 4096 Sunday
Javanese jv 0x1000 4096 Sunday
Javanese (Indonesia) jv-Latn-ID 0x1000 4096 Sunday
Javanese (Javanese) jv-Java 0x1000 4096 Sunday
Javanese (Javanese, Indonesia) jv-Java-ID 0x1000 4096 Sunday
Jola-Fonyi dyo 0x1000 4096
Jola-Fonyi (Senegal) dyo-SN 0x1000 4096
Kabuverdianu kea 0x1000 4096
Kabuverdianu (Cabo Verde) kea-CV 0x1000 4096
Kabyle kab 0x1000 4096 Saturday
Kabyle (Algeria) kab-DZ 0x1000 4096 Saturday
Kako kkj 0x1000 4096
Kako (Cameroon) kkj-CM 0x1000 4096
Kalenjin kln 0x1000 4096 Sunday
Kalenjin (Kenya) kln-KE 0x1000 4096 Sunday
Kamba kam 0x1000 4096 Sunday
Kamba (Kenya) kam-KE 0x1000 4096 Sunday
Kannada kn 0x4B 75
Kannada (India) kn-IN 0x44B 1099
Kanuri kr 0x71 113 Sunday
Kanuri (Nigeria) kr-NG 0x471 1137 Sunday
Kashmiri ks 0x60 96
Kashmiri (Devanagari) ks-Deva 0x1000 4096
Kashmiri (Devanagari, India) ks-Deva-IN 0x860 2144
Kashmiri (Perso-Arabic) ks-Arab 0x460 1120 Sunday
Kashmiri (Perso-Arabic) ks-Arab-IN 0x1000 4096 Sunday
Kazakh kk 0x3F 63
Kazakh (Kazakhstan) kk-KZ 0x43F 1087
Khmer km 0x53 83 Sunday
Khmer (Cambodia) km-KH 0x453 1107 Sunday
K'iche' quc-Latn 0x7C86 31878
K'iche' quc 0x86 134
K'iche' (Guatemala) quc-Latn-GT 0x486 1158
Kikuyu ki 0x1000 4096 Sunday
Kikuyu (Kenya) ki-KE 0x1000 4096 Sunday
Kinyarwanda rw 0x87 135
Kinyarwanda (Rwanda) rw-RW 0x487 1159
Kiswahili sw 0x41 65 Sunday
Kiswahili (Congo DRC) sw-CD 0x1000 4096
Kiswahili (Kenya) sw-KE 0x441 1089 Sunday
Kiswahili (Tanzania) sw-TZ 0x1000 4096
Kiswahili (Uganda) sw-UG 0x1000 4096
Konkani kok 0x57 87
Konkani (India) kok-IN 0x457 1111
Korean ko 0x12 18 Sunday
Korean (Korea) ko-KR 0x412 1042 Sunday
Korean (North Korea) ko-KP 0x1000 4096
Koyra Chiini khq 0x1000 4096
Koyra Chiini (Mali) khq-ML 0x1000 4096
Koyraboro Senni ses 0x1000 4096
Koyraboro Senni (Mali) ses-ML 0x1000 4096
Kurdish (Perso-Arabic, Iran) ku-Arab-IR 0x1000 4096 Saturday
Kwasio nmg 0x1000 4096
Kwasio (Cameroon) nmg-CM 0x1000 4096
Kyrgyz ky 0x40 64
Kyrgyz (Kyrgyzstan) ky-KG 0x440 1088
Lakota lkt 0x1000 4096 Sunday
Lakota (United States) lkt-US 0x1000 4096 Sunday
Langi lag 0x1000 4096
Langi (Tanzania) lag-TZ 0x1000 4096
Lao lo 0x54 84 Sunday
Lao (Lao P.D.R.) lo-LA 0x454 1108 Sunday
Latin la 0x76 118 Sunday
Latin (World) la-001 0x476 1142 Sunday
Latvian lv 0x26 38
Latvian (Latvia) lv-LV 0x426 1062
Lingala ln 0x1000 4096
Lingala (Angola) ln-AO 0x1000 4096
Lingala (Central African Republic) ln-CF 0x1000 4096
Lingala (Congo DRC) ln-CD 0x1000 4096
Lingala (Congo) ln-CG 0x1000 4096
Lithuanian lt 0x27 39
Lithuanian (Lithuania) lt-LT 0x427 1063
Low German nds 0x1000 4096
Low German (Germany) nds-DE 0x1000 4096
Low German (Netherlands) nds-NL 0x1000 4096
Lower Sorbian dsb 0x7C2E 31790
Lower Sorbian (Germany) dsb-DE 0x82E 2094
Luba-Katanga lu 0x1000 4096
Luba-Katanga (Congo DRC) lu-CD 0x1000 4096
Luo luo 0x1000 4096 Sunday
Luo (Kenya) luo-KE 0x1000 4096 Sunday
Luxembourgish lb 0x6E 110
Luxembourgish (Luxembourg) lb-LU 0x46E 1134
Luyia luy 0x1000 4096 Sunday
Luyia (Kenya) luy-KE 0x1000 4096 Sunday
Macedonian (Former Yugoslav Republic of Macedonia) mk-MK 0x42F 1071
Macedonian (FYROM) mk 0x2F 47
Machame jmc 0x1000 4096
Machame (Tanzania) jmc-TZ 0x1000 4096
Makhuwa-Meetto mgh 0x1000 4096 Sunday
Makhuwa-Meetto (Mozambique) mgh-MZ 0x1000 4096 Sunday
Makonde kde 0x1000 4096
Makonde (Tanzania) kde-TZ 0x1000 4096
Malagasy mg 0x1000 4096
Malagasy (Madagascar) mg-MG 0x1000 4096
Malay ms 0x3E 62
Malay (Brunei Darussalam) ms-BN 0x83E 2110
Malay (Latin, Singapore) ms-SG 0x1000 4096 Sunday
Malay (Malaysia) ms-MY 0x43E 1086
Malayalam ml 0x4C 76 Sunday
Malayalam (India) ml-IN 0x44C 1100 Sunday
Maltese mt 0x3A 58 Sunday
Maltese (Malta) mt-MT 0x43A 1082 Sunday
Manipuri mni 0x58 88
Manipuri (India) mni-IN 0x458 1112
Manx gv 0x1000 4096
Manx (Isle of Man) gv-IM 0x1000 4096
Maori mi 0x81 129
Maori (New Zealand) mi-NZ 0x481 1153
Mapudungun arn 0x7A 122 Sunday
Mapudungun (Chile) arn-CL 0x47A 1146 Sunday
Marathi mr 0x4E 78
Marathi (India) mr-IN 0x44E 1102
Masai mas 0x1000 4096 Sunday
Masai (Kenya) mas-KE 0x1000 4096 Sunday
Masai (Tanzania) mas-TZ 0x1000 4096
Mazanderani mzn 0x1000 4096 Saturday
Mazanderani (Iran) mzn-IR 0x1000 4096 Saturday
Meru mer 0x1000 4096 Sunday
Meru (Kenya) mer-KE 0x1000 4096 Sunday
Meta' mgo 0x1000 4096
Meta' (Cameroon) mgo-CM 0x1000 4096
Mohawk moh 0x7C 124 Sunday
Mohawk (Mohawk) moh-CA 0x47C 1148 Sunday
Mongolian mn 0x50 80
Mongolian (Cyrillic) mn-Cyrl 0x7850 30800
Mongolian (Cyrillic, Mongolia) mn-MN 0x450 1104
Mongolian (Traditional Mongolian) mn-Mong 0x7C50 31824
Mongolian (Traditional Mongolian, Mongolia) mn-Mong-MN 0xC50 3152
Mongolian (Traditional Mongolian, PRC) mn-Mong-CN 0x850 2128
Morisyen mfe 0x1000 4096
Morisyen (Mauritius) mfe-MU 0x1000 4096
Mundang mua 0x1000 4096
Mundang (Cameroon) mua-CM 0x1000 4096
Nama naq 0x1000 4096
Nama (Namibia) naq-NA 0x1000 4096
Nepali ne 0x61 97 Sunday
Nepali (India) ne-IN 0x861 2145 Sunday
Nepali (Nepal) ne-NP 0x461 1121 Sunday
Ngiemboon nnh 0x1000 4096
Ngiemboon (Cameroon) nnh-CM 0x1000 4096
Ngomba jgo 0x1000 4096
Ngomba (Cameroon) jgo-CM 0x1000 4096
N'ko nqo 0x1000 4096 Saturday
N'ko (Guinea) nqo-GN 0x1000 4096 Saturday
North Ndebele nd 0x1000 4096 Sunday
North Ndebele (Zimbabwe) nd-ZW 0x1000 4096 Sunday
Northern Luri lrc 0x1000 4096 Saturday
Northern Luri (Iran) lrc-IR 0x1000 4096 Saturday
Northern Luri (Iraq) lrc-IQ 0x1000 4096 Saturday
Norwegian no 0x14 20
Norwegian (Bokml) nb 0x7C14 31764
Norwegian (Nynorsk) nn 0x7814 30740
Norwegian, Bokml (Norway) nb-NO 0x414 1044
Norwegian, Bokml (Svalbard and Jan Mayen) nb-SJ 0x1000 4096
Norwegian, Nynorsk (Norway) nn-NO 0x814 2068
Nuer nus 0x1000 4096
Nuer (South Sudan) nus-SS 0x1000 4096
Nyankole nyn 0x1000 4096
Nyankole (Uganda) nyn-UG 0x1000 4096
Occitan oc 0x82 130
Occitan (France) oc-FR 0x482 1154
Odia or 0x48 72
Odia (India) or-IN 0x448 1096
Oromo om 0x72 114 Sunday
Oromo (Ethiopia) om-ET 0x472 1138 Sunday
Oromo (Kenya) om-KE 0x1000 4096 Sunday
Ossetian (Cyrillic, Georgia) os-GE 0x1000 4096
Ossetian (Cyrillic, Russia) os-RU 0x1000 4096
Ossetic os 0x1000 4096
Papiamento pap 0x79 121
Papiamento (Caribbean) pap-029 0x479 1145
Pashto ps 0x63 99 Saturday
Pashto (Afghanistan) ps-AF 0x463 1123 Saturday
Persian fa 0x29 41 Saturday
Persian (Iran) fa-IR 0x429 1065 Saturday
Polish pl 0x15 21
Polish (Poland) pl-PL 0x415 1045
Portuguese pt 0x16 22 Sunday
Portuguese (Angola) pt-AO 0x1000 4096
Portuguese (Brazil) pt-BR 0x416 1046 Sunday
Portuguese (Cabo Verde) pt-CV 0x1000 4096
Portuguese (Equatorial Guinea) pt-GQ 0x1000 4096
Portuguese (Guinea-Bissau) pt-GW 0x1000 4096
Portuguese (Luxembourg) pt-LU 0x1000 4096
Portuguese (Macao SAR) pt-MO 0x1000 4096 Sunday
Portuguese (Mozambique) pt-MZ 0x1000 4096 Sunday
Portuguese (Portugal) pt-PT 0x816 2070 Sunday
Portuguese (So Tomé and Príncipe) pt-ST 0x1000 4096
Portuguese (Switzerland) pt-CH 0x1000 4096
Portuguese (Timor-Leste) pt-TL 0x1000 4096
Prussian prg 0x1000 4096
Prussian (World) prg-001 0x1000 4096
Punjabi pa 0x46 70
Punjabi (Arabic) pa-Arab 0x7C46 31814
Punjabi (India) pa-IN 0x446 1094
Punjabi (Islamic Republic of Pakistan) pa-Arab-PK 0x846 2118
Quechua quz 0x6B 107 Sunday
Quechua (Bolivia) quz-BO 0x46B 1131 Sunday
Quechua (Ecuador) quz-EC 0x86B 2155 Sunday
Quechua (Peru) quz-PE 0xC6B 3179
Ripuarian (Germany) ksh-DE 0x1000 4096
Romanian ro 0x18 24
Romanian (Moldova) ro-MD 0x818 2072
Romanian (Romania) ro-RO 0x418 1048
Romansh rm 0x17 23
Romansh (Switzerland) rm-CH 0x417 1047
Rombo rof 0x1000 4096
Rombo (Tanzania) rof-TZ 0x1000 4096
Rundi rn 0x1000 4096
Rundi (Burundi) rn-BI 0x1000 4096
Russian ru 0x19 25
Russian (Belarus) ru-BY 0x1000 4096
Russian (Kazakhstan) ru-KZ 0x1000 4096
Russian (Kyrgyzstan) ru-KG 0x1000 4096
Russian (Moldova) ru-MD 0x819 2073
Russian (Russia) ru-RU 0x419 1049
Russian (Ukraine) ru-UA 0x1000 4096
Rwa rwk 0x1000 4096
Rwa (Tanzania) rwk-TZ 0x1000 4096
Saho ssy 0x1000 4096
Saho (Eritrea) ssy-ER 0x1000 4096
Sakha sah 0x85 133
Sakha (Russia) sah-RU 0x485 1157
Samburu saq 0x1000 4096 Sunday
Samburu (Kenya) saq-KE 0x1000 4096 Sunday
Sami (Inari) smn 0x703B 28731
Sami (Lule) smj 0x7C3B 31803
Sami (Northern) se 0x3B 59
Sami (Skolt) sms 0x743B 29755
Sami (Southern) sma 0x783B 30779
Sami, Inari (Finland) smn-FI 0x243B 9275
Sami, Lule (Norway) smj-NO 0x103B 4155
Sami, Lule (Sweden) smj-SE 0x143B 5179
Sami, Northern (Finland) se-FI 0xC3B 3131
Sami, Northern (Norway) se-NO 0x43B 1083
Sami, Northern (Sweden) se-SE 0x83B 2107
Sami, Skolt (Finland) sms-FI 0x203B 8251
Sami, Southern (Norway) sma-NO 0x183B 6203
Sami, Southern (Sweden) sma-SE 0x1C3B 7227
Sango sg 0x1000 4096
Sango (Central African Republic) sg-CF 0x1000 4096
Sangu sbp 0x1000 4096
Sangu (Tanzania) sbp-TZ 0x1000 4096
Sanskrit sa 0x4F 79 Sunday
Sanskrit (India) sa-IN 0x44F 1103 Sunday
Scottish Gaelic gd 0x91 145
Scottish Gaelic (United Kingdom) gd-GB 0x491 1169
Sena seh 0x1000 4096 Sunday
Sena (Mozambique) seh-MZ 0x1000 4096 Sunday
Serbian sr 0x7C1A 31770
Serbian (Cyrillic) sr-Cyrl 0x6C1A 27674
Serbian (Cyrillic, Bosnia and Herzegovina) sr-Cyrl-BA 0x1C1A 7194
Serbian (Cyrillic, Kosovo) sr-Cyrl-XK 0x1000 4096
Serbian (Cyrillic, Montenegro) sr-Cyrl-ME 0x301A 12314
Serbian (Cyrillic, Serbia) sr-Cyrl-RS 0x281A 10266
Serbian (Latin) sr-Latn 0x701A 28698
Serbian (Latin, Bosnia and Herzegovina) sr-Latn-BA 0x181A 6170
Serbian (Latin, Kosovo) sr-Latn-XK 0x1000 4096
Serbian (Latin, Montenegro) sr-Latn-ME 0x2C1A 11290
Serbian (Latin, Serbia) sr-Latn-RS 0x241A 9242
Sesotho (Lesotho) st-LS 0x1000 4096
Sesotho sa Leboa nso 0x6C 108 Sunday
Sesotho sa Leboa (South Africa) nso-ZA 0x46C 1132 Sunday
Setswana tn 0x32 50 Sunday
Setswana (Botswana) tn-BW 0x832 2098 Sunday
Setswana (South Africa) tn-ZA 0x432 1074 Sunday
Shambala ksb 0x1000 4096
Shambala (Tanzania) ksb-TZ 0x1000 4096
Shona sn 0x1000 4096 Sunday
Shona (Latin) sn-Latn 0x1000 4096 Sunday
Shona (Latin, Zimbabwe) sn-Latn-ZW 0x1000 4096 Sunday
Sindhi sd 0x59 89
Sindhi (Arabic) sd-Arab 0x7C59 31833
Sindhi (Devanagari) sd-Deva 0x1000 4096 Sunday
Sindhi (Devanagari, India) sd-Deva-IN 0x459 1113 Sunday
Sindhi (Islamic Republic of Pakistan) sd-Arab-PK 0x859 2137
Sinhala si 0x5B 91
Sinhala (Sri Lanka) si-LK 0x45B 1115
Slovak sk 0x1B 27
Slovak (Slovakia) sk-SK 0x41B 1051
Slovenian sl 0x24 36
Slovenian (Slovenia) sl-SI 0x424 1060
Soga xog 0x1000 4096
Soga (Uganda) xog-UG 0x1000 4096
Somali so 0x77 119
Somali (Djibouti) so-DJ 0x1000 4096 Saturday
Somali (Ethiopia) so-ET 0x1000 4096 Sunday
Somali (Kenya) so-KE 0x1000 4096 Sunday
Somali (Somalia) so-SO 0x477 1143
South Ndebele nr 0x1000 4096 Sunday
South Ndebele (South Africa) nr-ZA 0x1000 4096 Sunday
Southern Sotho st 0x30 48
Southern Sotho (South Africa) st-ZA 0x430 1072
Spanish es 0xA 10
Spanish (Argentina) es-AR 0x2C0A 11274 Sunday
Spanish (Belize) es-BZ 0x1000 4096 Sunday
Spanish (Venezuela) es-VE 0x200A 8202
Spanish (Bolivia) es-BO 0x400A 16394
Spanish (Brazil) es-BR 0x1000 4096
Spanish (Chile) es-CL 0x340A 13322
Spanish (Colombia) es-CO 0x240A 9226 Sunday
Spanish (Costa Rica) es-CR 0x140A 5130
Spanish (Cuba) es-CU 0x5C0A 23562
Spanish (Dominican Republic) es-DO 0x1C0A 7178 Sunday
Spanish (Ecuador) es-EC 0x300A 12298
Spanish (El Salvador) es-SV 0x440A 17418 Sunday
Spanish (Equatorial Guinea) es-GQ 0x1000 4096
Spanish (Guatemala) es-GT 0x100A 4106 Sunday
Spanish (Honduras) es-HN 0x480A 18442 Sunday
Spanish (Latin America) es-419 0x580A 22538
Spanish (Mexico) es-MX 0x80A 2058 Sunday
Spanish (Nicaragua) es-NI 0x4C0A 19466 Sunday
Spanish (Panama) es-PA 0x180A 6154 Sunday
Spanish (Paraguay) es-PY 0x3C0A 15370 Sunday
Spanish (Peru) es-PE 0x280A 10250 Sunday
Spanish (Philippines) es-PH 0x1000 4096 Sunday
Spanish (Puerto Rico) es-PR 0x500A 20490 Sunday
Spanish (Spain) es-ES 0xC0A 3082
Spanish (United States) es-US 0x540A 21514 Sunday
Spanish (Uruguay) es-UY 0x380A 14346
Standard Moroccan Tamazight zgh 0x1000 4096 Saturday
Standard Moroccan Tamazight (Tifinagh) zgh-Tfng 0x1000 4096 Saturday
Standard Moroccan Tamazight (Tifinagh, Morocco) zgh-Tfng-MA 0x1000 4096 Saturday
Swati ss 0x1000 4096
Swati (South Africa) ss-ZA 0x1000 4096
Swati (Eswatini former Swaziland) ss-SZ 0x1000 4096
Swedish sv 0x1D 29
Swedish (land Islands) sv-AX 0x1000 4096
Swedish (Finland) sv-FI 0x81D 2077
Swedish (Sweden) sv-SE 0x41D 1053
Syriac syr 0x5A 90 Sunday
Syriac (Syria) syr-SY 0x45A 1114 Sunday
Tachelhit shi 0x1000 4096 Saturday
Tachelhit (Latin) shi-Latn 0x1000 4096 Saturday
Tachelhit (Latin, Morocco) shi-Latn-MA 0x1000 4096 Saturday
Tachelhit (Tifinagh) shi-Tfng 0x1000 4096 Saturday
Tachelhit (Tifinagh, Morocco) shi-Tfng-MA 0x1000 4096 Saturday
Taita dav 0x1000 4096 Sunday
Taita (Kenya) dav-KE 0x1000 4096 Sunday
Tajik tg 0x28 40
Tajik (Cyrillic) tg-Cyrl 0x7C28 31784
Tajik (Cyrillic, Tajikistan) tg-Cyrl-TJ 0x428 1064
Tamazight tzm 0x5F 95
Tamazight (Latin) tzm-Latn 0x7C5F 31839
Tamazight (Latin, Algeria) tzm-Latn-DZ 0x85F 2143
Tamazight (Tifinagh) tzm-Tfng 0x785F 30815
Tamil ta 0x49 73
Tamil (India) ta-IN 0x449 1097
Tamil (Malaysia) ta-MY 0x1000 4096
Tamil (Singapore) ta-SG 0x1000 4096 Sunday
Tamil (Sri Lanka) ta-LK 0x849 2121
Tasawaq twq 0x1000 4096
Tasawaq (Niger) twq-NE 0x1000 4096
Tatar tt 0x44 68
Tatar (Russia) tt-RU 0x444 1092
Telugu te 0x4A 74
Telugu (India) te-IN 0x44A 1098
Teso teo 0x1000 4096
Teso (Kenya) teo-KE 0x1000 4096 Sunday
Teso (Uganda) teo-UG 0x1000 4096
Thai th 0x1E 30
Thai (Thailand) th-TH 0x41E 1054
Tibetan bo 0x51 81
Tibetan (India) bo-IN 0x1000 4096 Sunday
Tibetan (PRC) bo-CN 0x451 1105
Tigre tig 0x1000 4096
Tigre (Eritrea) tig-ER 0x1000 4096
Tigrinya ti 0x73 115
Tigrinya (Eritrea) ti-ER 0x873 2163
Tigrinya (Ethiopia) ti-ET 0x473 1139 Sunday
Tongan to 0x1000 4096
Tongan (Tonga) to-TO 0x1000 4096
Tsonga ts 0x31 49 Sunday
Tsonga (South Africa) ts-ZA 0x431 1073
Turkish tr 0x1F 31
Turkish (Cyprus) tr-CY 0x1000 4096
Turkish (Turkey) tr-TR 0x41F 1055
Turkmen tk 0x42 66
Turkmen (Turkmenistan) tk-TM 0x442 1090
Ukrainian uk 0x22 34
Ukrainian (Ukraine) uk-UA 0x422 1058
Upper Sorbian hsb 0x2E 46
Upper Sorbian (Germany) hsb-DE 0x42E 1070
Urdu ur 0x20 32
Urdu (India) ur-IN 0x820 2080
Urdu (Islamic Republic of Pakistan) ur-PK 0x420 1056
Uyghur ug 0x80 128
Uyghur (PRC) ug-CN 0x480 1152
Uzbek uz 0x43 67
Uzbek (Cyrillic) uz-Cyrl 0x7843 30787
Uzbek (Cyrillic, Uzbekistan) uz-Cyrl-UZ 0x843 2115
Uzbek (Latin) uz-Latn 0x7C43 31811
Uzbek (Latin, Uzbekistan) uz-Latn-UZ 0x443 1091
Uzbek (Perso-Arabic) uz-Arab 0x1000 4096 Saturday
Uzbek (Perso-Arabic, Afghanistan) uz-Arab-AF 0x1000 4096 Saturday
Vai vai 0x1000 4096
Vai (Latin) vai-Latn 0x1000 4096
Vai (Latin, Liberia) vai-Latn-LR 0x1000 4096
Vai (Vai) vai-Vaii 0x1000 4096
Vai (Vai, Liberia) vai-Vaii-LR 0x1000 4096
Valencian (Spain) ca-ES-valencia 0x803 2051
Venda ve 0x33 51 Sunday
Venda (South Africa) ve-ZA 0x433 1075 Sunday
Vietnamese vi 0x2A 42
Vietnamese (Vietnam) vi-VN 0x42A 1066
Volapük vo 0x1000 4096
Volapük (World) vo-001 0x1000 4096
Vunjo vun 0x1000 4096
Vunjo (Tanzania) vun-TZ 0x1000 4096
Walser wae 0x1000 4096
Walser (Switzerland) wae-CH 0x1000 4096
Welsh cy 0x52 82
Welsh (United Kingdom) cy-GB 0x452 1106
Wolaytta wal 0x1000 4096 Sunday
Wolaytta (Ethiopia) wal-ET 0x1000 4096 Sunday
Wolof wo 0x88 136
Wolof (Senegal) wo-SN 0x488 1160
Yangben yav 0x1000 4096
Yangben (Cameroon) yav-CM 0x1000 4096
Yi ii 0x78 120
Yi (PRC) ii-CN 0x478 1144
Yiddish yi 0x3D 61
Yiddish (World) yi-001 0x43D 1085
Yoruba yo 0x6A 106
Yoruba (Benin) yo-BJ 0x1000 4096
Yoruba (Nigeria) yo-NG 0x46A 1130
Zarma dje 0x1000 4096
Zarma (Niger) dje-NE 0x1000 4096
The locale identifier LOCALE_CUSTOM_UNSPECIFIED (0x1000, or 4096) is assigned to any culture that does not have a unique locale identifier and does not have complete system-provided data. Not all software packages will fully support all locales, so for example SQL database sort orders may not handle alphabetical sorting for every locale correctly even when the OS does. Related: Time Zones Language Identifier Constants and Strings - MSDN. PowerShell script to generate this page. ISO 3166 - Codes for countries and dependent territories. ISO 639-1 - Codes for languages. ISO 8601 - Standard date and time notation. CHCP - active console Code Page.

Sgn

Returns the sign of a number Syntax Sgn(Number) Key Number The number to return the sign of. If number > 0, then Sgn() will return 1. If number = 0, then Sgn() will return 0. If number < 0, then Sgn() will return -1. Example Dim intDemo intDemo = Sgn(64) MsgBox intDemo “One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs” ~ Robert Firt Related: IsNumeric - Is expression a Numeric?

The wscript.Shell + Shell.Application objects

Provides access to OS Shell methods. Syntax Set objShell = CreateObject("Wscript.Shell") Methods .AppActivate 'Activate running command. .Run 'Run an application .TileVertically 'Tile app windows .RegRead 'Read from registry .RegDelete 'Delete from registry .RegWrite 'Write to the registry Syntax Set objShell = CreateObject("Shell.Application") Methods .CanStartStopService("ServiceName") 'Can the current user start/stop the named service? .CascadeWindows 'Arrange app windows .EjectPC 'Eject PC from a docking station .Explore(FolderPath) 'Open a folder .FileRun 'Open the File-run dialogue .GetSystemInformation("PhysicalMemoryInstalled") 'Physical memory installed, in bytes. .IsServiceRunning("ServiceName") 'Check if a Windows service is running .MinimizeAll 'Minimize everything .NameSpace("C:\\") 'Create an object reference to a folder .ServiceStart("ServiceName", true) 'Start a windows service .ServiceStop("ServiceName", true) 'Stop a windows service .SetTime 'Open the set time GUI .ShellExecute 'Run a script or application .ShutdownWindows .TileHorizontally 'Tile app windows .TileVertically 'Tile app windows .ToggleDesktop 'Show/Hide Desktop .TrayProperties 'Display the Taskbar/Start Menu Properties .UndoMinimizeAll 'Un-Minimize everything Example Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "C:\Demo" Set objShell = Nothing “It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne Related: .AppActivate - Activate running command. .Application BrowseForFolder/Open .Run a command.

The wscript.Shell + Shell.Application objects

Provides access to OS Shell methods. Syntax Set objShell = CreateObject("Wscript.Shell") Methods .AppActivate 'Activate running command. .Run 'Run an application .TileVertically 'Tile app windows .RegRead 'Read from registry .RegDelete 'Delete from registry .RegWrite 'Write to the registry Syntax Set objShell = CreateObject("Shell.Application") Methods .CanStartStopService("ServiceName") 'Can the current user start/stop the named service? .CascadeWindows 'Arrange app windows .EjectPC 'Eject PC from a docking station .Explore(FolderPath) 'Open a folder .FileRun 'Open the File-run dialogue .GetSystemInformation("PhysicalMemoryInstalled") 'Physical memory installed, in bytes. .IsServiceRunning("ServiceName") 'Check if a Windows service is running .MinimizeAll 'Minimize everything .NameSpace("C:\\") 'Create an object reference to a folder .ServiceStart("ServiceName", true) 'Start a windows service .ServiceStop("ServiceName", true) 'Stop a windows service .SetTime 'Open the set time GUI .ShellExecute 'Run a script or application .ShutdownWindows .TileHorizontally 'Tile app windows .TileVertically 'Tile app windows .ToggleDesktop 'Show/Hide Desktop .TrayProperties 'Display the Taskbar/Start Menu Properties .UndoMinimizeAll 'Un-Minimize everything Example Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "C:\Demo" Set objShell = Nothing “It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne Related: .AppActivate - Activate running command. .Application BrowseForFolder/Open .Run a command.

ShellExecute method

Run a script or application in the Windows Shell. Syntax .ShellExecute "application", "parameters", "dir", "verb", window .ShellExecute 'some program.exe', '"some parameters with spaces"', , "runas", 1 Key application The file to execute (required) parameters Arguments for the executable dir Working directory verb The operation to execute (runas/open/edit/print) window View mode application window (normal=1, hide=0, 2=Min, 3=max, 4=restore, 5=current, 7=min/inactive, 10=default) Note that double " and single ' quotes that can be used to delimit paths with spaces. The runas verb can be used to elevate permissions. This was undocumented up until 2020 but is now official. When a script is run with elevated permissions several aspects of the user environment may change: The current directory, the current TEMP folder and any mapped drives will be disconnected. runas will fail if you are running in WOW64 (a 32 bit process on 64 bit windows) for example %systemroot%\syswow64\cmd.exe ... The ShellExecute method is a member of the IShellDispatch2 object. Examples Run a batch script with elevated permissions, flag=runas: Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "E:\demo\batchScript.cmd", "", "", "runas", 1 Run a VBScript with elevated permissions, flag=runas: Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "cscript", "E:\demo\vbscript.vbs", "", "runas", 1 “If you don't execute your ideas, they die” ~ Roger Von Oech Related: Run with elevated permissions - Script to run as Admin. .Exec - Execute command, returning an object. .Run - Run a command. joeware.net - CPAU (Create Process As User) like RunAs but with an option to encrypt the password. Equivalent CMD command: ShellRunAs - Run a command under a different user account.

WScript.Sleep

Suspend the execution of the current script for the specified number of milliseconds. Syntax WScript.Sleep lngTime Arguments: lngTime is the delay in milliseconds Sleep is a wscript method. Example WScript.Sleep(5000) WScript.Echo("5 seconds have passed.") “Success isn't permanent, and failure isn't fatal” ~ Mike Ditka Related: Equivalent Windows CMD commands: SLEEP - Wait for x seconds, WAITFOR - Wait for or send a signal. Equivalent PowerShell cmdlet: Start-sleep

Space

Return a string consisting of a specified number of spaces. Syntax Space(number) Key number The number of spaces to add to the string. Example wscript.echo "Hello" & Space(10) & "World" ' Insert 10 spaces between two strings. “Who looks outside, dreams; who looks inside, awakes” ~ Carl Gustav Jung Related: LCase - Return String in lower case.

WshShell.SpecialFolders

Obtain the full path to any of the special Windows folders (Desktop, Start Menu etc). Syntax strMyPath = objShell.SpecialFolders("strFolderName") or strMyPath = objShell.SpecialFolders.Item("strFolderName") Arguments: objShell A WScript.Shell object strFolderName : One of the following special folders (not all are available to all flavors of Windows) AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup Desktop Favorites Fonts MyDocuments NetHood PrintHood Programs Recent SendTo StartMenu Startup Templates Returns: strMyPath : The full path to the special folder returns NULL if the folder is not available. These special folders do not work in all language locales, a preferred method is to query the value from User Shell folders like this example vbscript. Examples Return the full path to the Windows Desktop: 'findDesktop.vbs Dim objShell Dim strPath Set objShell = Wscript.CreateObject("Wscript.Shell") strPath = objShell.SpecialFolders("Desktop") wscript.echo strPath A CMD batch file in the same folder can then read the Desktop location with one line: FOR /F "delims=" %%i in ('cscript %~dp0\findDesktop.vbs //nologo') DO Set _DeskTopDir=%%i List all special folders: For Each strFolder In WScript.CreateObject("Wscript.Shell").SpecialFolders MsgBox strFolder Next “An artist who was once known as Prince On the stage he would wiggle and mince And then, for a giggle, He changed his name to a squiggle And nobody's heard of him since” ~ Tim Brooke-Taylor Related Shell: folder - Shortcuts to key folders. User Shell Folders - Profile, Start Menu - Location of user profile folders. Equivalent in PowerShell: environment variables or (Get-WMIObject Win32_OperatingSystem).SystemDirectory

Split

Parse a string of delimited values into an array. Syntax Split(expression [,Delimiter [,count [,compare]]] ) Key expression The string expression to be broken up into an array. Delimiter The character used to separate items (default=a space " ") count The number of strings compare vbBinaryCompare (0) or vbTextCompare(1) Example vaPrices = Split("23.50, 67.50, 45.99, 18.47", ",") WScript.Echo vaPrices(0) > 23.50 “A gentle stream can split a mountain, given enough time” Related: Array - Add values to an Array variable. Join - Combine the contents of an array into a single variable. Equivalent in PowerShell: .Split method.

Sqr

Return the square root of a number. Syntax Sqr(number) Key number A valid numeric expression greater than or equal to zero. Examples Dim intDemo intDemo = Sqr (16) 'Returns: 4 “All human actions have one or more of these seven causes: chance, nature, compulsions, habit, reason, passion and desire” ~ Aristotle Related: Asc - The Ascii code of a character. Exp(n) - Return e (base of natural logs) raised to a power n.

.StdOut.ReadLine

Obtain User Input from the command prompt or retrieve (screen scrape) text from the output of a program. Syntax .StdOut.ReadLine() Examples ' Read a single line into a variable Dim strMyName WScript.StdOut.Write("Enter Your full Name>") WScript.StdIn.Read(0) strMyName = WScript.StdIn.ReadLine() WScript.StdOut.Write(strMyName) ' Read program output into a variable line by line Dim ObjExec Dim strFromProc Set objShell = WScript.CreateObject("WScript.Shell") Set ObjExec = objShell.Exec("cmd.exe /c dir") Do strFromProc = ObjExec.StdOut.ReadLine() WScript.Echo "ABC " & strFromProc & " DEF" Loop While Not ObjExec.Stdout.atEndOfStream “The unexamined life is not worth living” ~ Socrates Related: InputBox - Prompt for user input. .StdOut.Write - Text output. Equivalent PowerShell cmdlet: Read-Host - Read a line of input from the host console.

StrComp

Compare two strings. Syntax StrComp(String1, String2 [,compare] ) Key String1 A string expression. String2 A string expression. compare vbBinaryCompare (0) or vbTextCompare(1) If string1 = string2 StrComp returns 0 (vbFalse) If string1 < string2 StrComp returns -1 (vbTrue) If string1 > string2 StrComp returns 1 If either string = null StrComp returns null Example strPerson ="Hilary" result = StrComp("Hilary", strPerson) WScript.Echo result “If you want to marry wisely, marry your equal” ~ Spanish Proverb Related: Replace - Find and replace text. Equivalent in PowerShell: [String]::Compare or the CompareTo method or comparison operators.

String

Create a string with a single character repeated. Syntax String(Number, character ) Key Number The number of characters. character The character to repeat. Example result = string(25, "#") WScript.Echo result “If you want to marry wisely, marry your equal” ~ Spanish Proverb Related: StrComp - Compare two strings Equivalent in PowerShell: via multiplication: $result = "#" * 20

StrReverse

Reverse a string. Syntax StrReverse(String_expression) Key String_expression The string to reverse. Example result = StrReverse("Hello World") WScript.Echo result > dlroW olleH “The reverse side also has a reverse side” - Japanese Proverb Related: StrComp - Compare two strings. Equivalent in PowerShell: for ($i = $forward.length - 1; $i -ge 0; $i--) {$backward = $backward + ($forward.substring($i,1))}

Sub()

Declare the name, arguments, and code that form the body of a Sub procedure. Syntax [Public [Default] | Private] Sub Name [(arglist)] [statements] [Exit Sub] [statements] End Sub Public Indicates that the Sub procedure is accessible to all other procedures in all scripts. Default Used only with the Public keyword in a Class block to indicate that the Sub procedure is the default method for the class. An error occurs if more than one Default procedure is specified in a class. Private Indicates that the Sub procedure is accessible only to other procedures in the script where it is declared. name Name of the Sub; follows standard variable naming conventions. arglist List of variables representing arguments that are passed to the Sub procedure when it is called. Commas separate multiple variables. statements Any group of statements to be executed within the body of the Sub procedure. The arglist argument has the following syntax and parts: [ByVal | ByRef] varname[( )]
ByVal Indicates that the argument is passed by value. ByRef Indicates that the argument is passed by reference. If ByVal and ByRef are omitted, the default is ByRef. varname Name of the variable representing the argument; follows standard variable naming conventions.
Call a Sub procedure by using the procedure name followed by the argument list. Like a Function procedure, a Sub procedure is a separate procedure that can take arguments, perform a series of statements, and change the value of its arguments.A Sub procedure does not return a value, so it cannot be used in an expression. If not explicitly specified using either Public or Private, Sub procedures are public by default. The Exit Sub statement causes an immediate exit from a Sub procedure. Program execution continues with the statement that follows the statement that called the Sub procedure. Any number of Exit Sub statements can appear anywhere in a Sub procedure. Example Demo 64, 6 Sub Demo(value1, value2) Dim intAnswer intAnswer = value1 + value2 MsgBox "The sum is: " & intAnswer End Sub “A man practices the art of adventure when he breaks the chain of routine and renews his life through reading new books, traveling to new places, making new friends, taking up new hobbies and adopting new viewpoints” ~ Wilfred Peterson Related: Exit - Exit a subroutine. Function - Define a function procedure.

Time

Return the current system time. Syntax Time The Time() function may include a daylight savings adjustment. Example dim dtmCreated dtmCreated = Time “Beauty is Nature's coin, must not be hoarded, but must be current” ~ John Milton Related: Now - Return the current date and time. Date - Return the current date.

TimeSerial

Construct a Time value from Hours, Minutes and seconds. Syntax TimeSerial(Hour, Minute ,Second) Key Hour A numeric hour (0-23) Minute A numeric minute (0-59) Second A numeric second (0-59) Example result = TimeSerial(14,30,07) WScript.Echo result > 14:30:07 “Time is more valuable than money. You can get more money, but you cannot get more time” ~ Jim Rohn Related: Replace - Find and replace text. Equivalent PowerShell cmdlet: $result = get-date -h 17 -mi 10 -s 45 -displayhint time

TimeValue

Convert a string to a Time value. Syntax TimeValue(StringTime) Key StringTime A string containing a valid time Example result = TimeValue("14:30") WScript.Echo result > 14:30:00 “Time is more valuable than money. You can get more money, but you cannot get more time” ~ Jim Rohn Related: TimeSerial - Construct a Time value from Hours and Minutes. Equivalent in PowerShell: $result = [datetime] "11:59 AM"

Trim

Remove leading and trailing spaces from a string. Syntax Trim(string) Key string A text string or string expression. Examples Dim strDemo strDemo = Trim(" The world is everlasting ") Returns "The world is everlasting" “The hands of every clock are shears, trimming us away scrap by scrap, and every time piece with a digital readout blinks us towards implosion” ~ Dean Koontz Related: LTrim - Remove leading spaces from a string. RTrim Remove trailing spaces from a string.

TypeName

Return variable type (variant subtype). Syntax TypeName(varname) Key varname The name of the variable TypeName() has the following return values:
Value Description
Byte Byte value
Integer Integer value
Long Long integer value
Single Single-precision floating-point value
Double Double-precision floating-point value
Currency Currency value
Decimal Decimal value
Date Date or time value
String Character string value
Boolean Boolean value; True or False
Empty Uninitialized
Null No valid data
<object type> Actual type name of an object
Object Generic object
Unknown Unknown object type
Nothing Object variable that has been explicitly set to Nothing, or has been set to return the value of a function that returned Nothing
Error Error
Variant() A Variant array
Examples Dim MyType MyType = TypeName("SS64") ' Returns "String". MyType = TypeName(4) ' Returns "Integer". MyType = TypeName(37.50) ' Returns "Double". “Who looks outside, dreams; who looks inside, awakes” - Carl Gustav Jung Related: Dim - Declare a new variable or array variable. Equivalent in PowerShell: Use a comparison operator $myvar -is [bool]

UBound

Return the largest subscript for an array dimension. Syntax UBound(arrayname[, dimension]) Key arrayname The name of the array variable dimension The array dimension as a whole number 1 for the first dimension, 2 for the second etc (default=1) The UBound function is used with the LBound Function to determine the size of an array. Use LBound to find the lower limit of an array dimension. Example Dim Arr(5,10,12) result = UBound(Arr, 1) WScript.Echo result “Who looks outside, dreams; who looks inside, awakes” - Carl Gustav Jung Related: Array(el1,el2,el3) - Add values to an Array variable. Dim - Declare a new variable or array variable. LBound - Return the smallest subscript for an array. Equivalent in PowerShell: $arrDemo.getupperbound(0) or $arrDemo.length-1

Ucase

Convert a string to upper-case. Syntax Ucase(string) Key string A string or string expression. Examples Dim strDemo strDemo = Ucase("12 Acacia Gardens") Msgbox strDemo Returns "12 ACACIA GARDENS " “Those who cannot hear an angry shout may strain to hear a whisper” ~ Leonard Nimoy Related: LCase - Convert a string to lower-case. If..Then - Conditionally execute a block of statements.

UnEscape

Return Unicode characters from an escaped ASCII string. Syntax UnEscape(String) Key String The encoded string of text to convert to standard Ascii text. Example Option Explicit Dim strMessage, strUnescaped strMessage = "Sample text with (parentheses) spaces & " & Chr(34) & "quotes" & Chr(34) MsgBox strMessage & vbCR & Escape(strMessage), vbOkOnly+vbInformation, "Demo" strUnEscaped = UnEscape (strMessage) MsgBox strUnEscaped & vbCR & Escape(strMessage), vbOkOnly+vbInformation, "UnEscaped" “Writing is a form of therapy; sometimes I wonder how all those, who do not write, compose, or paint can manage to escape the madness, the melancholia, the panic fear, which is inherent in a human condition” ~ Graham Greene Related: Escape - Return only ASCII characters from a Unicode string.

Weekday

Return the day of the week. Syntax Weekday(Date [,FirstDayofWeek]) Key Date A date expression FirstDayofWeek A constant that specifies the first day of the week, default=vbSunday. To create day numbers compatible with ISO 8601 standard dates, set thefirstdayofweek to Monday(2 or vbMonday) Example Dim intDay intDay = Weekday("30/04/2012",2) WScript.Echo intDay > 1 Weekday() will return one of the following constant values: vbSunday 1 vbMonday 2 vbTuesday 3 vbWednesday 4 vbThursday 5 vbFriday 6 vbSaturday 7 “Write it on your heart that every day is the best day in the year” ~ Ralph Waldo Emerson Related: DateAdd - Add a time interval to a Date. DateDiff - Return the time interval between two dates. DatePart - Return a unit of time from a date. WeekdayName - Return the named day of the week. Equivalent PowerShell cmdlet: (Get-Date).DayOfWeek.Value__ + 1 (The underscores give a number and the +1 is because PS counts from 0)

WeekdayName

Return the named day of the week. Syntax WeekdayName(DayNum[,Abbreviate [,FirstDayofWeek]]) Key DayNum A date expression Abbreviate Abbreviate the day: Monday>Mon... (TRUE/FALSE) FirstDayofWeek An integer for the first day of the week DayNum is one of the following constant values: vbSunday 1 vbMonday 2 vbTuesday 3 vbWednesday 4 vbThursday 5 vbFriday 6 vbSaturday 7 Example result = WeekdayName(6) WScript.Echo result > Friday “Name the day of marriage, and God will give thee joy” - Shakespeare Related: DateAdd - Add a time interval to a Date. DateDiff - Return the time interval between two dates. DatePart - Return a unit of time from a date. Weekday - Return the day of the week. Equivalent in PowerShell: $result = (get-date "12/31/2010").dayofweek

While ... WEnd

Repeat a block of statements. Syntax While condition [Statements] WEnd Key condition An expression that evaluates to True or False Statements Program code to be executed if condition is True Example endLoop = DateAdd("s",10,Time()) While Time() < endLoop WScript.Echo "This line will repeat for 10 seconds" Wend “Don’t ask what the world needs. Ask what makes you come alive, and go do it. Because what the world needs is people who have come alive” ~ Howard Thurman Related: If..Then - Conditionally execute a block of statements. Select...Case - Conditional execution of a block of code. Do..Loop - Repeat a block of statements. Equivalent PowerShell cmdlet: While

With

Assign multiple properties of an object. Syntax With object [Statements] End with Key object A previously defined object variable Statements Program code to be executed against object Example Msg = "First line" & vbCrLf & "Second line" Set objWord = CreateObject("Word.Application") objWord.Visible = True With objWord .Documents.Add .Selection.TypeText Msg .Selection.WholeStory End With “We could have made beautiful music together” ~ Clifford Odets (movie: The General Died at Dawn) Related: CreateObject - Create a WSH automation object.

Year

Return a four-digit year (a number from 1900 to 9999) for a given date value. Syntax Year(date_value) Key date_value A valid date. Examples Dim intDemo intDemo = Year(dtmShiftEnd) intDemo = Year(#31/12/2012#) Select * from orders where Year(Order_date) = 2012; “I'm spending a year dead for tax reasons” ~ Douglas Adams Related: Day - Return the day of the month. DatePart - Return part of a given date. Month - Return the month for a given date. GetDate.vbs - Return the current Year/month/Day and time.

REM

Include explanatory remarks in a VBScript program. Syntax ' comment command ' comment REM comment command : REM comment If a REM statement is added on the same line as a command, then it must be prefixed with a colon (the end-of-line statement). This is not required when using the apostrophe comment prefix. Examples Dim MyStr1, MyStr2 MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed. #Now stand in the place where you work, Now face West Think about the place where you live, Wonder why you haven't before# ~ REM 'Stand' Related: Echo - Echo text to screen.