JSI Tip 8979. How can I use the command-line, or a batch, to disable Windows XP Professional System Restore on one or all drives?

Jerold Schulman

January 25, 2005

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

I have scripted DisableRP.bat to disable Windows XP Professional System Restore on one or all drives.

The syntax for using DisableRP.bat is:

DisableRP Drive RetVal

Where Drive is the drive letter of the drive on which you want to disable System Restore, or ALL to disable it on all drives, and RetVal is a call directed environment variable that will contain a Y if the script was successful, or a N is the script failed to disable the requested object.

NOTE: If you disable System Restore on the boot drive, System Restore will be disabled on all drives.

NOTE: The boot drive is the drive that contains the Windows folder, and the system drive is the drive that contains the files that Windows uses to start, like Boot.ini, NTLDR, etc..

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 test the status of the last Windows XP Professional System Restore?

DisableRP.bat contains:

@echo offif {%2}=={} @echo Syntax: DisableRP Drive RetVal&goto :EOFsetlocalset work=%1if /i "%work%" NEQ "ALL" set drive=%work:~0,1%:set DisableRPVBS="%TEMP%DisableRP_%RANDOM%.VBS"set OK=N@echo Set objArgument = Wscript.Arguments>%DisableRPVBS%@echo If objArgument.Count() ^> 0 Then>>%DisableRPVBS%@echo Drive =  objArgument(0)>>%DisableRPVBS%@echo Else>>%DisableRPVBS%@echo Drive = "">>%DisableRPVBS%@echo End If>>%DisableRPVBS%@echo Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")>>%DisableRPVBS%@echo If (obj.Disable(Drive)) = 0 Then>>%DisableRPVBS%@echo     wscript.Echo "Y">>%DisableRPVBS%@echo Else>>%DisableRPVBS%@echo     wscript.Echo "N">>%DisableRPVBS%@echo End If>>%DisableRPVBS%for /f "Tokens=*" %%d in ('cscript //nologo %DisableRPVBS% %drive%') do ( set OK=%%d)del /q %DisableRPVBS%endlocal&set %2=%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