In tip 1407, I described the Net View command.
If I type net view \\JSI001, it displays:
HP2250 Print HP Business Inkjet 2250 PCL 5C HP2250T1 Print HP Business Inkjet 2250 Top Tray HPOJRx80i Print HP Office Jet Rx80i ... ... ... NETLOGN Disk Logon server share SYSVOL Disk Logon Server Share ... ... ... ... ... ... The command completed successfully.If you have a many shares, it is difficult to find the printers.
I have scripted ShowPrinters.bat to display the printers only, or to allow you to further process the printer shares.
The syntax for using ShowPrinters.bat is:
ShowPrinters \\PrintServer
The \\ in front of the computer name of the print server is optional.
If I run ShowPrinters \\JSI001, it returns:
\\jsi001\HP2250,HP Business Inkjet 2250 PCL 5C \\jsi001\HP2250T1,HP Business Inkjet 2250 Top Tray \\jsi001\HPOJRx80i,HP Office Jet Rx80iIf I wanted to process the list of printers in a batch file, I would script:
for /f "Tokens=1 Delims=," %%i in ('call ShowPrinters \\JSI001') do call :MyLabel "%%i"which would pass the following to MyLabel:
"\\jsi001\HP2250" "\\jsi001\HP2250T1" "\\jsi001\HPOJRx80i"ShowPrinters.bat contains:
@echo off setlocal if \{%1\}==\{\} goto syntax set computer=%1 set computer=%computer:"=% set computer=\\%computer:\=% for /f "Skip=7 Tokens=*" %%p in ('net view %computer%') do set entry=%%p&call :findprt endlocal goto :EOF :syntax @echo Syntax: ShowPrinters \\Server endlocal goto :EOF :strip set printer=%printer:"=% set printer=%printer: ##=##% set printer=%printer: ##=##% set printer=%printer: ##=##% set printer=%printer: ##=##% goto :EOF :findprt if /i not "%entry:~13,5%" EQU "Print" goto :EOF set printer=%entry:~0,13%## set Comment=%entry:~35,99% :chkprinter set work=%printer: ##=##% if not "%work%" EQU "%printer%" call :strip "%printer%"&goto chkprinter set printer=%printer:##=% @echo %computer%\%printer%,%comment%
0 comments
Hide comments