Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for loghist.bat

(view source code of loghist.bat as plain text)

  1. @ECHO OFF
  2. :: Current script version
  3. SET MyVer=1.11
  4.  
  5. :: Windows NT 4 or later only
  6. IF NOT "%OS%"=="Windows_NT" GOTO W9xSyntax
  7.  
  8. :: Need on screen help?
  9. IF NOT [%1]==[] GOTO Syntax
  10.  
  11. :: Remove existing history log file
  12. IF EXIST "%UserName%.hst" DEL "%UserName%.hst"
  13.  
  14. :: Windows 2000 -- and probably XP as well -- use a different path
  15. VER | FIND " 5." >NUL
  16. IF NOT ERRORLEVEL 1 SET LocalSet=\Local Settings
  17.  
  18. :: Progress notes are written to console only
  19. SET Message=Gathering data, this may take quite a while . .
  20. CLS
  21. >CON ECHO.
  22. >CON ECHO.%Message%
  23.  
  24. :: Search recursively
  25. FOR /R "%UserProfile%%LocalSet%\History" %%A IN (index.dat) DO CALL :SrchIndex "%%A"
  26.  
  27. :: Remove any leftovers in the TEMP directory
  28. IF EXIST "%Temp%.\%~n0.dat" DEL "%Temp%.\%~n0.dat"
  29.  
  30. :: Done
  31. >CON ECHO.
  32. >CON ECHO Done.
  33. >CON ECHO.
  34. >CON ECHO The data collected has been stored in a file named "%UserName%.hst".
  35. GOTO End
  36.  
  37. :SrchIndex
  38. :: Progress note
  39. SET Message=%Message% .
  40. CLS
  41. >CON ECHO.
  42. >CON ECHO.%Message%
  43. :: Write the URLs to a temporary file
  44. TYPE %1 2>NUL | FIND "://" > "%Temp%.\%~n0.dat"
  45. :: Filter the URLs from the saved lines and write them to the history log
  46. FOR /F "tokens=1* delims=@" %%a IN ('TYPE "%Temp%.\%~n0.dat" ^| SORT') DO (IF NOT "%%b"=="" >>"%UserName%.hst" ECHO.%%b)
  47. GOTO:EOF
  48.  
  49. :Syntax
  50. :: On screen message is written to standard error
  51. (ECHO.) 1>&2
  52. (ECHO LogHist.bat,  Version %MyVer% for Windows NT 4 / 2000 / XP) 1>&2
  53. (ECHO Write a list of visited URLs to a file) 1>&2
  54. (ECHO.) 1>&2
  55. (ECHO Usage:  %~n0) 1>&2
  56. (ECHO.) 1>&2
  57. (ECHO A file will be created ^(or overwritten^) in the current directory,) 1>&2
  58. (ECHO named after the user currently logged in:  %%UserName%%.hst.) 1>&2
  59. (ECHO.) 1>&2
  60. (ECHO Written by Rob van der Woude) 1>&2
  61. (ECHO http://www.robvanderwoude.com) 1>&2
  62. GOTO End
  63.  
  64. :W9xSyntax
  65. ECHO.
  66. ECHO LogHist.bat,  Version %MyVer%, for Windows NT 4 / 2000 / XP only
  67. ECHO Write a list of visited URLs to a file
  68. ECHO.
  69. ECHO Usage:  LOGHIST
  70. ECHO.
  71. ECHO A file will be created (or overwritten) in the current directory,
  72. ECHO named after the user currently logged in:  %%UserName%%.hst.
  73. ECHO.
  74. ECHO Written by Rob van der Woude
  75. ECHO http://www.robvanderwoude.com
  76.  
  77. :End
  78. SET LocalSet=
  79. SET Message=
  80. SET MyVer=
  81.  

page last modified: 2024-04-16; loaded in 0.0086 seconds