|
Answer» looking for a batch file to disable system restore. All i found is this site .. http://www.jsifaq.com/subr/tip8900/rh8979.htm but i cant seem to get the script working ... im still new and learning on batch files. can anyone help me with the script on that site to work on local machine.
I also found a vb script to disable system restore.. its working wonderfull.
Option Explicit
Dim strComputerName, blnEnabled, objRP, lngRC
' If no command-line parameters, assume local computer If Wscript.Arguments.Count = 0 Then strComputerName = CreateObject("Wscript.Network").ComputerName ELSE strComputerName = Wscript.Arguments(0) End If
' Check if computer has any restore points blnEnabled = False For Each objRP In GetObject("WinMgmts:" _ & "{impersonationlevel=impersonate}!//" & strComputerName _ & "/root/default").InstancesOf("SystemRestore") blnEnabled = True Exit For Next
lngRC = 0
If blnEnabled Then ' Disable System Restore for all drives on the computer lngRC = GetObject("WinMgmts:" _ & "{impersonationlevel=impersonate}!//" & strComputerName _ & "/root/default:SystemRestore").Disable("") If lngRC = 0 Then Wscript.Echo "Disabled System Restore on " _ & strComputerName & "." Else Wscript.Echo "Error &H" & Hex(lngRC) & " disabling System Restore" _ & " on " & strComputerName & "." End If Else Wscript.Echo "System Restore is already disabled on " _ & strComputerName & "." End If
Wscript.Quit lngRC
can system restore be disabled from a batchfile???This is probably more a case of the right tool for the right job than anything else. Wscript is the right tool. While you can apparently do it in batch it will be MUCH easier to do and configure in script. Sort of like cutting down a tree with a hand saw when you have a chain saw available in your tool box.
Are you getting any erros with the batch file? If so what are they? How are you calling this batch file? Are you passing parameters to the batch file?
all i get is this .. when i run the file ..
@echo off if {%2}=={} @echo Syntax: DisableRP Drive RetVal&goto :EOF setlocal set work=%1 if /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%
It wan't you to provide it the input parameters "Drive" and "RetVal". So if I READ the batch file correctly then you need to provide it with the drive letter you want to disable system restore on and a "Y"
So to run it for drive C: you type
DisableRP C: Y
then press enter.ohh .. i get it now.. cool .. i need to specify which drive or type ALL for all drive. Yes or No .. thanks man ... now that i understand it .. i can learn more about the code. Thanks ALOT gussery
|