Microsoft KB Archive/295299

= How To Use the System Restore Utility with Windows Management Instrumentation in Windows XP =

Article ID: 295299

Article Last Modified on 1/15/2006

-

APPLIES TO


 * Microsoft Windows XP Professional
 * Microsoft Windows XP Home Edition

-



This article was previously published under Q295299



IN THIS TASK
SUMMARY
 * Requirements
 * To Create a System Restore Point
 * To Disable or Enable System Restore for a Particular Drive
 * To Enumerate System Restore Points on a Computer
 * To Roll Back to a Specific Restore Point

REFERENCES



SUMMARY
This article describes how you can use the System Restore utility to create, enumerate, and restore previously created restore points by using Windows Management Instrumentation (WMI).

back to the top

Requirements
To run WMI, you must have administrator privileges. You can use System Restore by means of WMI and the Srclient.dll file.

The following VBScript code excerpts are minimal examples. This code must not be implemented without prior error checking and full testing.

back to the top

To Create a System Restore Point
'use WMI moniker and SystemRestore class set SRP = getobject(&quot;winmgmts:\\.\root\default:Systemrestore&quot;) CSRP = SRP.createrestorepoint (&quot;this is a test&quot;, 0, 100)

back to the top

To Disable or Enable System Restore for a Particular Drive
onoff = inputbox (&quot;Do you want enable or disable System Restore?&quot;, &quot;System Restore&quot;) Drive = inputbox (&quot;Which Drive would you like to take action on? Must type in format 'c:\'&quot;,

&quot;Drive to enable/disable&quot;)

set SRP = GetObject(&quot;winmgmts:\\.\root\default:SystemRestore&quot;)

If onoff = &quot;enable&quot; then eSRP = SRP.enable(drive) end if

If onoff = &quot;disable&quot; then eSRP = SRP.disable(drive) end if

back to the top

To Enumerate System Restore Points on a Computer
set SRP = getobject(&quot;winmgmts:\\.\root\default&quot;).InstancesOf (&quot;systemrestore&quot;) for each Point in SRP msgbox point.creationtime & vbcrlf & point.description & vbcrlf & &quot;Sequence Number= &quot; & point.sequencenumber next The dates are returned in yyyymmddHHMMSS.mmmmmmsUUU format, where:

yyyy= a four digit year

mm= a two digit month

dd= a two digit day of the month

HH= a two digit hour of the day (00-23)

SS= seconds (00-59)

mmmmmm= microseconds

s= plus (+) or minus (-) sign to signify the positive or negative offset from coordinated universal time (UTC)

UUU= an offset in minutes that the originating time zone deviates from UTC

NOTE: You cannot filter items based on specific dates. The filter process begins at the first restore points and enumerates from that location. If you want to filter items, you need to script a filter to narrow down the dates that are based on the values that are returned.

back to the top

To Roll Back to a Specific Restore Point
NOTE: Do not use this function without also calling a computer shutdown. System Restore may not work properly if a restart of the computer is not initiated immediately. set SRP = getobject(&quot;winmgmts:\\.\root\Default:SystemRestore&quot;) eSRP = SRP.Restore(22) 'parameter passed is the sequence number of the restore point you want to roll back to.

back to the top

