April 2004
Beginner
416 pages
11h 3m
English
To use the Reg.exe tool to back up the registry, it is necessary to create an instance of the WshShell class. This allows you to launch programs that are not part of Windows Scripting Host. The following program, RegBack.vbs, illustrates making a hook into WshShell:
Option Explicit
dim objShell
WScript.Echo("beginning " & Now)
Set objShell = CreateObject("WScript.Shell")
objShell.Exec "%comspec% /k reg.exe EXPORT HKLM c:\hklm.reg"
WScript.Echo("completed " & Now)As you can see in RegBack.vbs, you declare a variable called objShell and set it equal to the hook that comes back from using CreateObject to create an instance of WshShell.
After we have this hook into the Shell object, you use the Exec method to launch a command-line ...