Object References
There are some operations that can be performed with the Windows Script Host regardless of the language being used. These operations, such as accessing the filesystem, are made possible by extending the language with objects. For the time being, we can consider an object to be simply a context that is referred to when carrying out certain commands.
Admittedly, this can make carrying out some tasks rather difficult and convoluted, but it is necessary given the modular architecture of WSH. For example, many scripts will require a line similar to the following (using VBScript syntax in this case):
Set WshShell = WScript.CreateObject("WScript.Shell")which creates and initializes the WshShell object. WshShell is not a visible object like a file
or other component of Windows, but rather a required reference used to
accomplish many tasks with WSH, such as running programs, creating
Windows shortcuts, and retrieving system information.
If you're unfamiliar with object references, your best bet is to
simply type them as shown and worry about how they actually work when
you're more comfortable with the language. The subsequent topics include
many solutions that take advantage of objects, such as WScript.Shell, which has many uses, and
Scripting.FileSystemObject, used for
accessing files,
folders, and drives.
Running Applications from Scripts
This code is used to run a program, which can be a DOS
program, a Windows application, an Internet or
mailto URL, or anything else ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access