Personally, I like using Call; it makes references to my custom subroutines
more distinct and easier to find, but others might prefer the simpler form.
Object References | 523
Scripting and
Automation
The solutions in the subsequent topics are presented as either subroutines or
functions. I??™ve used subroutines for code that performs an action, such as
copying a file or writing information to the Registry. When a result is
expected, such as reading information from the Registry or finding the date
of a file, a function is used instead.
You should be able to place the subroutines and functions directly into your
scripts and call them with a single command. It??™s up to you to put the pieces
together (and to modify them) to accomplish whatever tasks you have in mind.
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, consider an object to be simply a context that is
referred to when certain commands are carried out.
Admittedly, this can make executing some tasks rather difficult and convoluted,
but it is necessary given the modular architecture of WSH. For example,
many scripts 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.
Pages:
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728