Jump to content

System Restore Batch?


Recommended Posts

Hey guys,

Here at the shop, when we install windows a-fresh, the last thing we do (next to scandisk and defrag) is clearing the system restore. To do this we simply turn it off, then turn it back on again.

I am in the process of automating our whole software installation/configuration procedure, and I'd like to be able to do that systemrestore thing in batch/registry.

Thanks in advance for your help!

Jon

Link to comment
Share on other sites


Here try this VBS script. It will Disable SystemRestore wait for a minute then Enable SystemRestore

Save As Stop_Start_SR.vbs

 Option Explicit 
Dim Computer, Result, SR, Wmi
Computer = "."
Set Wmi = GetObject _
("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\default")
'/->Disable SystemRestore
Set SR = Wmi.Get("SystemRestore")
Result = SR.Disable("")
'/->Stop Script For Approx 1 Minute
WScript.Sleep 60000
'/->Enable SystemRestore
Result = SR.Enable("")

Link to comment
Share on other sites

Here try this VBS script. It will Disable SystemRestore wait for a minute then Enable SystemRestore

Save As Stop_Start_SR.vbs

 Option Explicit 
Dim Computer, Result, SR, Wmi
Computer = "."
Set Wmi = GetObject _
("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\default")
'/->Disable SystemRestore
Set SR = Wmi.Get("SystemRestore")
Result = SR.Disable("")
'/->Stop Script For Approx 1 Minute
WScript.Sleep 60000
'/->Enable SystemRestore
Result = SR.Enable("")

Using the WMI method you could even go one step further and create a single new one for the customer too.
Set SRP = GetObject("winmgmts:\\.\root\default:SystemRestore")
DSRP = SRP.Disable("")
ESRP = SRP.Enable("")
CSRP = SRP.CreateRestorePoint ("Factory Settings", 0, 100)

BTW, I don't think that the wait between disable and enable is necessary.

Link to comment
Share on other sites

Hey Gunsmokinman & Yzowl,

Cool feedback, I wanted to send out MY appreciation too (also to JonWatson for asking, great idea). Should be something I'll use also, automation is great. :w00t:

Edited by VCC
Link to comment
Share on other sites

  • 3 weeks later...

You guys rock.

Here's something ironic... I sent a customer home with a new computer the other day and he installed a second hard drive with another install of windows on it (and it was screwed up a bit...). Needless to say, his new Windows installation got a bit confused (as did said customer) and things got a little messed up. So he thought he'd run System Restore and try and fix things.

Well, he had rushed me to get it done far too quickly and I neglected to reset System Restore (bad idea! I've learned my lesson)... now he has bad clusters all over his restore files, and it's even worse because he restored to a point when his system was incomplete!

Point being...I encourage all technicians and system builders to use the NET STOP and START method (or whichever you find easiest) and make sure that service gets reset!!!

Thanks again guys

Jon

Link to comment
Share on other sites

You both had good ideas, but there's a more efficient way to do it

1 - Copy depends.exe and depends.exe from the xp or 2003 support tools and paste them into your system32 folder

2 - Open depends and open srclient.dll. See screenshot below

All of these functions can be run from the command line

example

rundll32 srclient.dll,DisableSR

That should disable system restore. NOTE: It's case sensitive!

-gosh

post-7679-1195083118_thumb.jpg

Link to comment
Share on other sites

My point is net stop and net start doesn't let you customize anything. For example, let's say you want to create a restore point from the command line or change the settings. Stopping a service won't let you do that. Stopping a service to disable functionality is very crude. What if Microsoft changes system restore in a future version of windows to not delete restore points when the service is stopped?

-gosh

Link to comment
Share on other sites

It's true, it could be a poor way to do it in the future. However I don't foresee Microsoft making any changes like that to XP, especially after SP3 is out. Vista might be another question, but for now I'm not too worried about it. We don't really roll out a lot of Vista machines. We are based (for now) in a very... simple town, to put it nicely. It's a logging community that grew, basically. Lots of old retired lumberjacks with various missing apendages.

For now, so it's not so rube goldberg, I'm using the net stop method. What we're doing is very basic, so I'm not worried.

Thanks for the input though, I'll definitely keep it in mind in the future!

Jon

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...