Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for defprn2k.bat

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

  1. @ECHO OFF
  2. ECHO.
  3.  
  4. :: No command line parameters required
  5. IF NOT [%1]==[] GOTO Syntax
  6. :: Tested in Windows 2000 only
  7. VER | FIND "Windows 2000" >NUL
  8. IF ERRORLEVEL 1 GOTO Syntax
  9.  
  10. :: Read default printer from registry and store in temporary file
  11. REGEDIT /E %TEMP%.\DefPRN.dat "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
  12. :: Read default printer from temporary file
  13. FOR /F "tokens=2 delims=,=" %%A IN ('TYPE %TEMP%.\DefPRN.dat ^| FIND "Device"') DO SET DefPRN=%%A
  14. :: Remove temporary file
  15. DEL %TEMP%.\DefPRN.dat
  16. :: Remove quotes from variable and display its value
  17. SET DefPRN=%DefPRN:"=%
  18. SET DefPRN
  19.  
  20. :: Done
  21. GOTO End
  22.  
  23. :Syntax
  24. ECHO DefPRN2K.bat,  Version 1.00 for Windows 2000
  25. ECHO Display default printer
  26. ECHO.
  27. ECHO Usage:  %~n0
  28. ECHO.
  29. ECHO Written by Rob van der Woude
  30. ECHO http://www.robvanderwoude.com
  31.  
  32. :End
  33.  

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