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.
How to Run Applications
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 you might
normally type in the Start menu??™s Run command or Explorer??™s address bar.
Place this subroutine in your scripts:
Sub RunProgram(Filename, Wait)
Set WshShell = WScript.CreateObject("WScript.Shell")
RetVal = WshShell.Run(Filename, Wait)
End Sub
524 | Chapter 9: Scripting and Automation
and call the routine like this:
Call RunProgram("c:\windows\notepad.exe", True)
You can replace True with False if you don??™t want to wait for the program to
finish before the next script command is executed.
See the next sidebar, ???Scripting and the UAC,??? for important security
considerations.
How to Access the Registry
The following code is used to write, read, and delete information in the Registry.
Pages:
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729