The automation capabilities in Windows are supported at the operating system level. They are provided by the Windows Script Host component, which is capable of executing scripts in various programming languages. Initially, the OS delivery set includes interpreters for JScript and VBScript languages. The last one is mainly used to create vbs scripts that solve administration and user management tasks.
Necessary
text editor
Instructions
Step 1
Explore the features and capabilities of the runtime environment under which the created script should function. For example, if a script is intended to be embedded in web pages, it will interact heavily with the browser object model and the current document (BOM and DOM). Scripts developed to run under Windows Script Host (for example, to automate administrative tasks) will interact with its object model, through which they can easily create and use other ActiveX and COM objects.
Step 2
Develop algorithms that will be used to create the main functionality of the script. Apply knowledge of the capabilities provided by the runtime environment. Identify the parts of the algorithms that can be implemented in the form of procedures, functions, methods of classes. Identify data that can be encapsulated in classes.
Step 3
Implement a stub of the future script. In a text editor, create a file. Add function and procedure "stubs" to it, as well as class declarations containing their methods. A procedure in VBScript is declared with the Sub keyword followed by an identifier that specifies its name. The End Sub clause is a sign of the end of the procedure body. For example:
Sub MyProcedure (a, b)
End Sub
Similarly, functions are declared using the Function keyword:
Function MyFunction (a)
End Function
Classes are declared using the Class keyword:
Class MyClass
End Class
Step 4
Declare global, local variables and class members. This is done with the Dim clause:
Dim MyVariable
By specifying the dimension after the variable name, you can declare arrays:
Dim MyArray (10) 'array of ten elements;
Dim MyArray (10, 15) 'two-dimensional array;
Dim MyArray () 'dynamic array.
Step 5
Implement data processing algorithms by adding code to functions, procedures, and class methods. Use the Do - Loop, While - Wend, For - Each - Next, For - To - Step - Next clauses to create loops. Use the If - Then - ElseIf - Else - End If clause as the branching statement and the Select Case - End Select clause as the multiple choice statement.
Step 6
Add comments to the code. They must come after the single quote character or the Rem keyword. For example:
'comment text
Rem comment text