Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for capture.bat

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

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Check command line arguments (only 1, optional)
  6. IF NOT "%~2"=="" GOTO Syntax
  7. IF NOT "%~1"=="" IF NOT EXIST "%~f1" GOTO Syntax
  8. ECHO "%~1" | FINDSTR.EXE /R /C:"[/?*]" >NUL && GOTO Syntax
  9.  
  10. :: Navigate to the default directory for CAPTURE.TIF
  11. PUSHD C:\
  12.  
  13. :: Navigate to an alternative directory, if specified
  14. CD /D "%~f1" 2>NUL
  15.  
  16. :: No directory is no problem, non-existing directory is
  17. IF ERRORLEVEL 1 (
  18. 	POPD
  19. 	GOTO Syntax
  20. )
  21.  
  22. :: Locate the IrfanView main executable
  23. START /WAIT REGEDIT.EXe /E "%Temp%.\~capture.tmp" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView"
  24.  
  25. :: Abort if IrfanView wasn't found
  26. IF NOT EXIST "%Temp%.\~capture.tmp" GOTO Syntax
  27.  
  28. :: Use IrfanView to capture the screen
  29. FOR /F "tokens=2 delims==" %%A IN ('TYPE "%Temp%.\~capture.tmp" ^| FINDSTR.EXE /R /I /C:".UninstallString.="') DO (
  30. 	"%%~dpAi_view32.exe" /capture /silent /append=capture.tif /killmesoftly
  31. )
  32.  
  33. :: Delete temporary file
  34. DEL "%Temp%.\~capture.tmp"
  35.  
  36. :: Done, return to original directory
  37. POPD
  38. GOTO:EOF
  39.  
  40.  
  41. :Syntax
  42. ECHO.
  43. ECHO Capture.bat,  Version 1.00 for Windows 2000 and later
  44. ECHO Append a screen dump to a multi-page TIF file
  45. ECHO.
  46. ECHO Usage:  CAPTURE.BAT  [ tif_dir ]
  47. ECHO.
  48. ECHO Where:  "tif_dir"  is the path where the multi-page TIF file
  49. ECHO                    "capture.tif" will be saved (default: C:\)
  50. ECHO.
  51. ECHO Note:   This batch file requires IrfanView (http://www.irfanview.com)
  52. ECHO.
  53. ECHO Written by Rob van der Woude
  54. ECHO http://www.robvanderwoude.com
  55.  

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