Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getprn2nt.bat

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

  1. @ECHO OFF
  2. :: GetPrn2.bat,  Version 1.00
  3. :: Displays network printers plus default
  4. :: printer for current user on current system.
  5. :: Written for "real" NT/2000 networks.
  6. :: Requires REG.EXE from the Microsoft Windows NT 4 Resource Kit
  7. ::
  8. :: Written by Rob van der Woude
  9. :: http://www.robvanderwoude.com
  10.  
  11. SETLOCAL
  12. ECHO.
  13. :: Delims is a comma, followed by a TAB and a space
  14. FOR /F "tokens=3* delims=,	 " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"') DO ECHO Default Printer   %%A
  15. ECHO.
  16. ECHO Printers defined on %computername%:
  17. FOR /F "skip=1 tokens=*" %%A IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers" ^| FIND "["') DO CALL :Enum "%%A"
  18. ENDLOCAL
  19. GOTO:EOF
  20.  
  21. :Enum
  22. ECHO.
  23. SET Printer=%1
  24. SET Printer=%Printer:"=%
  25. SET Printer=%Printer:[=%
  26. SET Printer=%Printer:]=%
  27. :: Delims is a TAB followed by a space
  28. FOR /F "tokens=2* delims=	 " %%a IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\%Printer%\Name"')           DO ECHO Name              %%b
  29. FOR /F "tokens=2* delims=	 " %%a IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\%Printer%\Description"')    DO ECHO Description       %%b
  30. FOR /F "tokens=3* delims=	 " %%a IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\%Printer%\Printer Driver"') DO ECHO Printer Driver    %%b
  31. FOR /F "tokens=2* delims=	 " %%a IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\%Printer%\Port"')           DO ECHO Port              %%b
  32. GOTO:EOF
  33.  

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