Search Tools Links Login

Domain change in progress, site content is moving! See this post for more info

Create a System Restore Point with VBscript

This handy little VBscript to create a system restore point can be encapsulated in a function, and can save you from yourself.

Lets say you're performing some automated functions on a group of machines.  Some of these operations might be changing/adding/deleting registry files, or making changes to drivers, or even (gasp!) fiddling with key system files.  One way to protect yourself is to perform a backup or image of the machine before starting.

But there is another way.  You can leverage the built-in feature of Windows to create system restore points, which will allow you to back out any changes that might have backfired in your script.  Watch out for line wrap below:

CONST DEVICE_DRIVER_INSTALL = 10
CONST BEGIN_SYSTEM_CHANGE = 100
strComputer = "TARGET COMPUTERNAME HERE"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.CreateRestorePoint("Scripted restore", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)

There you go.  Pretty straightforward, yes?  Hope this helps you out.

About this post

Posted: 2013-10-25
By: dwirch
Viewed: 2,054 times

Categories

Tip

Scripting

Visual Basic Script (VBS)

Windows

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

Sorry. Comments are frozen for this article. If you have a question or comment that relates to this article, please post it in the appropriate forum.