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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script: Mass Windows system restore reducer

Performance

Script: Mass Windows system restore reducer

by  hgate73  Posted    (Edited  )
I noticed one day that Windows XP was set by default (out of the box) to use a whopping 12% (!) of the hard drive for system restore points. That's HUGE. We don't need all those on our systems, so this script crawls through the network (or, if you like, only your computer) and flips a registry entry to reduce the amount of space used by Sys Restore. In this script it lowers it to 2%, but you can change that to anything you want.

It reads names of computers to affect from names.txt, one per line.

Code:
:: Author:          hgate73 at gmail or yahoo
:: Purpose:         Reduces the amount of disk space allowed to be used by System Restore
:: Requirements:    1. Run this script with admin privileges
::                  2. reg.exe from Microsoft must be in any of these locations:
::                      a) the directory you run this script from
::                      b) c:\windows\system32\    (preferred)
::                      c) in the PATH variable
::                  3. Put the names of your computers, one per line, in a file called "names.txt" in the same directory as this script
:: Version:         1.0 Initial write

:: Prep
@echo off
title Mass SysRestore Reducer
set VERSION=1.0
set NAMES_FILE=names.txt
cls

:: Manual
:start
echo.
echo  Mass SysRestore Reducer
echo.
echo  Enter the IP or name of the remote computer, or "autoreduce" to
echo  auto-reduce the space used by SysRestore on ALL computers in %NAMES_FILE%
echo.
:loop
@set /P TARGET= Target Computer:
if %TARGET%==exit goto end
if %TARGET%==autoreduce goto auto
:: /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
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
echo.
goto loop



:: HIROSHIMA!
:auto
title Mass SysRestore Reducing...
cls
echo.
echo Performing mass System Restore usage reduction.
echo Please wait...
echo.
:: We use a FOR loop to iterate through the list of system names.
:: %%i      is the current computer name read from the file
FOR /F %%i in (%NAMES_FILE%) do echo %%i && reg add "\\%%i\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" /v DiskPercent /t REG_DWORD /d 00000002 /f
FOR /F %%i in (%NAMES_FILE%) do echo %%i && reg add "\\%%i\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\Cfg" /v DiskPercent /t REG_DWORD /d 00000002 /f

title Mass SysRestore Reduce --  Complete
echo.
echo Mass SysRestore Reduce -- Complete
echo.
title %USERNAME%
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top