I have scripted RstRP.bat to restore a Windows XP Professional Restore Point from the command-line, or from a batch?
The syntax for using RstRP.bat is:
RstRP RPSeq
Where RPSeq is the Restore Point Sequence Number.
If RPSeq is valid, RstRP.bat will shutdown and restart the computer to restore the Restore Point.
NOTE: If RstRP.bat returns to the process that invoked it, the Restore Point Sequence Number was invalid.
To restore the last Restore Point:
setlocal
set RPSeq=N
for /f "Tokens=*" %%a in ('enumRP') do (
call :erp %%a
)
if "%RPSeq%" EQU "N" goto none
RstRP %RPSeq%
endlocal
goto :EOF
:none
@echo No Restore Points found.
endlocal
goto :EOF
:erp
set RPSeq=%1To restore the oldest
Restore Point:
setlocal
set RPSeq=N
for /f "Tokens=*" %%a in ('enumRP') do (
call :erp %%a
)
if "%RPSeq%" EQU "N" goto none
RstRP %RPSeq%
endlocal
goto :EOF
:none
@echo No Restore Points found.
endlocal
goto :EOF
:erp
if "%RPSeq%" EQU "N" set RPSeq=%1To restore the last
Restore Point taken on January 20, 2005:
setlocal
set RPSeq=N
for /f "Tokens=*" %%a in ('enumRP^|FIND "2005 01 20"') do (
call :erp %%a
)
if "%RPSeq%" EQU "N" goto none
RstRP %RPSeq%
endlocal
goto :EOF
:none
@echo No Restore Points found.
endlocal
goto :EOF
:erp
set RPSeq=%1NOTE: See the following tips:
How can I create a Restore Point in Windows XP, from the command-line, or from a batch?
How can I retrieve all the available Restore Points on a Windows XP Professional computer?
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?
RstRP.bat contains:
@echo off
if {%1}=={} @echo Syntax: RstRP RPSeqNumb&goto :EOF
setlocal
set RPSEQ=%1
set RstRPVBS="%TEMP%\RstRP_%RANDOM%.VBS"
set OK=N
@echo Set objArgument = Wscript.Arguments>%RstRPVBS%
@echo RpSeq = objArgument(0)>>%RstRPVBS%
@echo Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")>>%RstRPVBS%
@echo if obj.Restore(RpSeq) ^ 0 Then>>%RstRPVBS%
@echo wscript.Echo "N">>%RstRPVBS%
@echo else>>%RstRPVBS%
@echo wscript.Echo "Y">>%RstRPVBS%
@echo End If>>%RstRPVBS%
for /f "Tokens=*" %%s in ('cscript //nologo %RstRPVBS% %RPSEQ%') do (
set OK=%%s
)
del /q %RstRPVBS%
if "%OK%" EQU "Y" shutdown -r -t 01
endlocal