JSI Tip 8978. How can I test the status of the last Windows XP Professional System Restore?

Jerold Schulman

January 25, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

I have scripted TstLstSR.bat to test if the last System Restore was successful, or was interrupted, or failed.

The syntax for using TstLstSR.bat is:

TstLstSR RetVal

Where RetVal is a call directed environment variable that will contain:

Y   if the last System Restore was successful.
  if the last System Restore was interrupted.
N  if the last System Restore failed.

NOTE: 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 restore a Windows XP Professional Restore Point from the command-line, or from a batch?
How can I use the command-line, or a batch, to disable Windows XP Professional System Restore on one or all drives?

TstLstSR.bat contains:

@echo offif {%1}=={} @echo Syntax: TstLstSR RetVal&goto :EOFsetlocalset name=%1set TstLstSRVBS="%TEMP%TstLstSR_%RANDOM%.VBS"set OK=N@echo Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")>%TstLstSRVBS%@echo status = obj.GetLastRestoreStatus()>>%TstLstSRVBS%@echo If status = 0 Then>>%TstLstSRVBS%@echo     wscript.Echo "N">>%TstLstSRVBS%@echo ElseIf status = 1 Then >>%TstLstSRVBS%@echo     wscript.Echo "Y">>%TstLstSRVBS%@echo ElseIf status = 2 Then>>%TstLstSRVBS%@echo     wscript.Echo "I">>%TstLstSRVBS%@echo End If>>%TstLstSRVBS%for /f "Tokens=*" %%s in ('cscript //nologo %TstLstSRVBS%') do ( set OK=%%s)del /q %TstLstSRVBS%endlocal&set %1=%OK%



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like