JSI Tip 10547. How can I create a CSV file containing all the shared printers in my domain?

Using RmtShare.exe, I have scripted SharedPrinters.bat to generate a CSV file that contains all the shared printers in your domain.

The syntax for using SharedPrinters.bat is:

SharedPrinters CSVFile

Where CSVFile is the file that will contain the CSV file, with content like:

"\\JSI001\HP2250","HP Business Inkjet 2250 (PCL5C)"
"\\JSI009\HPOffice","HP Officejet 6200 series"
SharedPrinters.bat contains:
@echo off
if \{%1\}==\{\} @echo Syntax: SharedPrinters CSVFile&goto :EOF
set csvfile=%1
if exist %csvfile% del /q %csvfile%
set dom=%USERDOMAIN%
set b1=FIND /V ":"
set b2=FIND /V "The command completed successfully."
set b3=FIND "Path"
for /f "Tokens=1" %%c in ('net view /domain:%dom%^|Findstr /L /C:"\\"') do (
 set comp=%%c
 for /f "Skip=4 Tokens=*" %%p in ('rmtshare %%c^|%b1%^|%b2%') do (
 set line=%%p
 if "!line:~13,1!" NEQ " " call :prt !line:~0,12!
goto :EOF
for /f "Tokens=1*" %%x in ('rmtshare %comp%\%1^|%b3%') do (
 set work=%%y
 set work=!work:,LocalsplOnly=!
 @echo "%comp%\%1","!work!">>%csvfile%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.