Skip to Content
Microsoft® Windows® Scripting Self-Paced Learning Guide
book

Microsoft® Windows® Scripting Self-Paced Learning Guide

by Ed Wilson
April 2004
Beginner
416 pages
11h 3m
English
Microsoft Press
Content preview from Microsoft® Windows® Scripting Self-Paced Learning Guide

Creating the WshShell Object

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 ...

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.
Start your free trial

You might also like

Microsoft® Windows® 2000 Scripting Guide

Microsoft® Windows® 2000 Scripting Guide

Microsoft Corporation
Professional C# 5.0 and .NET 4.5.1

Professional C# 5.0 and .NET 4.5.1

Christian Nagel, Jay Glynn, Morgan Skinner

Publisher Resources

ISBN: 9780735619814Supplemental ContentCatalog PageErrata