When you use the Internet Explorer Tools menu to open Internet Options, the General tab allows you to configure Days to keep pages in history.

You can change this value in a batch, or logon script, by setting the DaysToKeep Value Name, a REG_DWORD data type, at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History.

Examples of setting DaysToKeep to 3:

Using REG.EXE, built into Windows XP, Windows Server 2003, and later, or installed from the Windows 2000 Support Tools on the operating system CD-ROM:

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History" /V DaysToKeep /T REG_DWORD /F /D 3

Using REGEDIT.EXE:

Regedit /s FileName.reg

Where FileName.reg contains:

REGEDIT4

\[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History\]
"DaysToKeep"=dword:00000003

Using a batch to generate a .REG file:

@echo off
setlocal
set rf="%TEMP%\DaysToKeep_%RANDOM%.TMP"
(
@echo REGEDIT4
@echo.
@echo \[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History\]
@echo "DaysToKeep"=dword:00000003
@echo.
)>%rf%
regedit /s %rf%
del /q %rf%
endlocal