Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 



JSI Tip 8975. How can I create a Restore Point in Windows XP, from the command-line, or from a batch?

RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

I described the process of creating and using a Restore Point in tip 4650 » How do I use Windows XP Professional's System Restore to undo problem changes.

I have scripted CrtRP.bat to create a Restore Point from the command-line, or from a batch.

The syntax for using CrtRP.bat is:

CrtRP Description RetVal

Where Description is the Restore point description and RetVal is a call directed environment variable that will contain a Y if the Restore Point was successfully created, or an N if the Restore Point creation failed.

Example:

CrtRP "Test CrtRP.bat" OK
If "%OK%" EQU "N" Goto RPFailed

NOTE: See the following tips:

How can I retrieve all the available Restore Points on a Windows XP Professional computer?
How can I restore a Windows XP Professional Restore Point from the command-line, or from a batch?
How can I test the status of the last Windows XP Professional System Restore?
How can I use the command-line, or a batch, to disable Windows XP Professional System Restore on one or all drives?

CrtRP.bat contains:

@echo off
if {%2}=={} @echo Syntax: CrtRP Description RetVal&goto :EOF
setlocal
set name=%1
set CrtRPVBS="%TEMP%\CrtRP_%RANDOM%.VBS"
set OK=N
@echo Set objArguments = Wscript.Arguments>%CrtRPVBS%
@echo CrtRPn = objArguments(0)>>%CrtRPVBS%
@echo Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")>>%CrtRPVBS%
@echo If (obj.CreateRestorePoint(CrtRPn, 0, 100)) = 0 Then>>%CrtRPVBS%
@echo     wscript.Echo "Y">>%CrtRPVBS%
@echo Else>>%CrtRPVBS%
@echo     wscript.Echo "N">>%CrtRPVBS%
@echo End If>>%CrtRPVBS%
for /f "Tokens=*" %%r in ('cscript //nologo %CrtRPVBS% %name%') do (
 set OK=%%r
)
del /q %CrtRPVBS%
endlocal&set %2=%OK%



End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. ...

Getting your iPhone to Sync with Exchange 2003

Follow these steps to use an iPhone with Exchange. ...


Windows OSs Whitepapers Protecting Microsoft SharePoint

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

7 Ways To Get More From Your SharePoint Deployment Now

Windows, Unix, Linux Interoperability

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement