C:\_G\WWW\~ELISANET\INFO\tscmd110.html
<http://www.elisanet.fi/tsalmi/info/tscmd110.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Fri 30-Nov-2018 11:40:55

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



110} Can I use a script to determine if a specific printer exists?

Let's start with displaying the default printer

  @echo off & setlocal enableextensions
  cscript C:\WINDOWS\system32\prnmngr.vbs -g
  endlocal & goto :EOF

The output could be e.g.
  C:\_D\TEST>cmdfaq
  The default printer is HP home DeskJet 500


  cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g

To list all of the printers for a computer
  @echo off & setlocal enableextensions
  cscript C:\WINDOWS\system32\prnmngr.vbs -l
  endlocal & goto :EOF

If the computer is on a network, for a specific printer one could try for example
  @echo off & setlocal enableextensions
  set find_=HP DeskJet 895Cxi
  net view \\%COMPUTERNAME%^
    |findstr /c:"Print "^
    |findstr /c:" %find_% ">nul
  if %errorlevel% EQU 0 (
    echo Found %find_%
    ) else (
    echo Did not find %find_%)
  endlocal & goto :EOF

The output would be e.g.
  C:\_D\TEST>cmdfaq
  Found HP DeskJet 895Cxi

The carets (^) in the code are used to divide a long command on multiple lines.

References/Comments:
  hh ntcmds.chm::/net_view.htm [You can't use this unless you have the ntcmds.chm file]
  hh ntcmds.chm::/findstr.htm
  prnmngr.vbs xp

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd110.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd110
http://www.elisanet.fi/tsalmi/info/tscmd110.html
file:///c:/_g/www/~elisanet/info/tscmd110.html