(view source code of loghist.bat as plain text)
@ECHO OFF
:: Current script version
SET MyVer=1.11
:: Windows NT 4 or later only
IF NOT "%OS%"=="Windows_NT" GOTO W9xSyntax
:: Need on screen help?
IF NOT [%1]==[] GOTO Syntax
:: Remove existing history log file
IF EXIST "%UserName%.hst" DEL "%UserName%.hst"
:: Windows 2000 -- and probably XP as well -- use a different path
VER | FIND " 5." >NUL
IF NOT ERRORLEVEL 1 SET LocalSet=\Local Settings
:: Progress notes are written to console only
SET Message=Gathering data, this may take quite a while . .
CLS
>CON ECHO.
>CON ECHO.%Message%
:: Search recursively
FOR /R "%UserProfile%%LocalSet%\History" %%A IN (index.dat) DO CALL :SrchIndex "%%A"
:: Remove any leftovers in the TEMP directory
IF EXIST "%Temp%.\%~n0.dat" DEL "%Temp%.\%~n0.dat"
:: Done
>CON ECHO.
>CON ECHO Done.
>CON ECHO.
>CON ECHO The data collected has been stored in a file named "%UserName%.hst".
GOTO End
:SrchIndex
:: Progress note
SET Message=%Message% .
CLS
>CON ECHO.
>CON ECHO.%Message%
:: Write the URLs to a temporary file
TYPE %1 2>NUL | FIND "://" > "%Temp%.\%~n0.dat"
:: Filter the URLs from the saved lines and write them to the history log
FOR /F "tokens=1* delims=@" %%a IN ('TYPE "%Temp%.\%~n0.dat" ^| SORT') DO (IF NOT "%%b"=="" >>"%UserName%.hst" ECHO.%%b)
GOTO:EOF
:Syntax
:: On screen message is written to standard error
(ECHO.) 1>&2
(ECHO LogHist.bat, Version %MyVer% for Windows NT 4 / 2000 / XP) 1>&2
(ECHO Write a list of visited URLs to a file) 1>&2
(ECHO.) 1>&2
(ECHO Usage: %~n0) 1>&2
(ECHO.) 1>&2
(ECHO A file will be created ^(or overwritten^) in the current directory,) 1>&2
(ECHO named after the user currently logged in: %%UserName%%.hst.) 1>&2
(ECHO.) 1>&2
(ECHO Written by Rob van der Woude) 1>&2
(ECHO http://www.robvanderwoude.com) 1>&2
GOTO End
:W9xSyntax
ECHO.
ECHO LogHist.bat, Version %MyVer%, for Windows NT 4 / 2000 / XP only
ECHO Write a list of visited URLs to a file
ECHO.
ECHO Usage: LOGHIST
ECHO.
ECHO A file will be created (or overwritten) in the current directory,
ECHO named after the user currently logged in: %%UserName%%.hst.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
SET LocalSet=
SET Message=
SET MyVer=
page last modified: 2024-04-16; loaded in 0.0086 seconds