Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable or change System Restore from the command-line? 1

Status
Not open for further replies.

GeneralDzur

Technical User
Jan 10, 2005
204
US
In my quest to script everything I possibly can to save me time on mundane tasks, I'm trying to figure out a way to either reduce the space System Restore uses (preferred) or disable it completely (other option) via the command-line. I've googled but can only find references to starting the GUI via the command-line, but that's not what I need. How can I reduce the space it uses? Maybe just stop and restart the service to kill off the restore points?
 
Stopping and starting the service doesn't kill any restore points. You have to edit the registry (in effect) to set the value of System Restore (on/off) and disk space dedicated to the system restore.


So, if you know of a DOS way to affect these registry values - that's what you need to change.

A possible how to here (yes both .coms are necessary)
 
The registry stores System Restore keys and values in three places. You can change registry values to configure System Restore, but I strongly recommend that you use the utility's UI to make changes whenever possible. Changing registry values can destabilize a system, so be careful.

The three registry subkeys are

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Sr
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SrService
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore

The first subkey controls System Restore's filter*don't alter this subkey in any way. The second subkey controls the System Restore service, and you shouldn't alter it in any way either. If you change either of these subkeys, you'll likely disrupt the functioning of your system.

The third subkey includes some values that you can change. You can increase the DiskPercent value to make more room available to store restore points. The default value is 12 percent of your hard disk, although the actual size might vary. For hard disks smaller than 4GB, the actual value is 400MB. You can also decrease this value if you have a hard disk larger than 4GB and don't want to give 12 percent of it to System Restore. To use the System Restore UI to change this setting, run the Control Panel System applet, select the System Restore tab, select a hard disk from the list of available drives, click Settings, and adjust the Disk space to use slider.

You can change the RPGlobalInterval value to specify the interval between System Restore's automatic creation of restore points. For example, to change the interval from every 24 hours to once a week, change the default value of 86,400 seconds to 604,800.

If for security reasons you don't want to save restore points for long periods, you can change the RPLifeInterval value. The default value is 7,776,000 seconds, or 90 days. To change the interval to 2 weeks, set the value to 1,209,600.

Again, don't change a value if you're not sure that it's safe to do so. See the Microsoft article "The Registry Keys and Values for the System Restore Utility" ( to learn more about which values are safe to alter.


Source: Windows & .NET Magazine"


How to add, modify, or delete registry subkeys and values by using a registration entries (.reg) file
 
Starting and stopping the service through the GUI actually does clear system restore points. See
The issue though, of course, is how to do this in an automated fashion. I've researched it, and what seems to be happening is that an API call gets made. Look into SRCLIENT.DLL to see what you can find. For what I've done ( faq102-6631 ), I found you could clear system restore points by index by calling SRRemoveRestorePoint. You could look into whether you can call RUNDLL32 to get this, or it might be easier to try to use VBScript to get this done.

I would have to research more, but there might be undocumented things to change the disk usage percentages for this as in API. But there is a WMI class which will do this:
If this doesn't get you where you need to go, by all means I can look into some other options (maybe even a cut down version of what is in that TT FAQ).

HTH.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
I think Linney is on track for what my needs are, I don't know any VBScript or API calls, but I can handle basic batch files. Still learning...

I'll use reg.exe to edit the entry and change the disk space used, the only thing I'm worried about is if it will get overwritten next time the PC reboots - i.e. if some other setting will clobber the one in the registry.

This is the line I ended up using (in a FOR loop):

Code:
reg add \\%TARGET%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore /v DiskPercent /t REG_DWORD /d 00000002 /f
reg add \\%TARGET%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\Cfg /v DiskPercent /t REG_DWORD /d 00000002 /f

where:
:: /v    value
:: /t    type (REG_DWORD in this case)
:: /d    data to assign to the value
:: /f    force overwriting the current value w/ no prompt

 
[/b]Starting and stopping the service through the GUI actually does clear system restore points."[/b]

The above is NOT shutting off the service. That is turning system restore OFF. Shutting off the System Restore service from SERVICES.MSC most certainly does NOT remove restore points which is what I was referring to. The service can be running but not actually making/managing restore points.

What you suggested is actually turning off system restore which could also be accomplished by the registry edit.
 
This is GeneralDzur, I'm using a new account.

I don't really want to turn the service off, it CAN be useful (in some odd situations), I just don't want it gobbling up 12% of every hard drive. The registry edit I did just changed it to use 2% of the total hard drive space. I verified this through the GUI afterwards, and it seems to have taken effect.

To summarize:
- Starting and stopping through the GUI removes all points
- Stopping the service (via services.msc or some other means) does NOT remove the points, only disabled new ones
- Editing the registry like I did just alters the % of space used

Is that correct?

I was previously posting under "GeneralDzur" but hgate73 is my new username.
 
- Starting and stopping through the GUI removes all points
Correct - if you do the following - it's not really starting & stopping the service, it's turning it on or off
Steps to turn off System Restore

1. Click Start, right-click My Computer, and then click Properties.
2. In the System Properties dialog box, click the System Restore tab.
3. Click to select the Turn off System Restore check box. Or, click to select the Turn off System Restore on all drives check box.
4. Click OK.
5. When you receive the following message, click Yes to confirm that you want to turn off System Restore:
You have chosen to turn off System Restore. If you continue, all existing restore points will be deleted, and you will not be able to track or undo changes to your computer.

Do you want to turn off System Restore?
After a few moments, the System Properties dialog box closes.


- Stopping the service (via services.msc or some other means) does NOT remove the points, only disabled new ones
CORRECT

- Editing the registry like I did just alters the % of space used
CORRECT
You can also change the percentage through the GUI as well, though probably not what you really care about, given your initial post title.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top