The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-28-2006
jallport jallport is offline
Registered User
 

Join Date: Mar 2006
Location: UK
Posts: 11
Very clunky, but:

for /f %i in ('net view') do net view %i | find "Print" >>result.txt

Explanation:
'net view' - command to display all sharing-enabled computers in a workgroup or domain.
'for /f %i ...' - for each line of result (%i) from 'net view', list the shares on that computer.
'| find "Print" - Pipe the preceding output through FIND.COM and look for the string "Print", indcating a shared printer.
'>>result.txt' - append the output to the file "result.txt", NOTE: >> to append, not > to write to or we'll only see the last positive match in our file.

The resulting file (result.txt in this case) will look something like:
[Netbios name, Service, Comment]

AC_PRN Print Accounts department multifunction

PR_DESJ Print Public Relations department Colour Deskjet

SH_DMP Print Shipping office dot-matrix label printer

Hope it helps.

If you want anything better I think you're going to have to look at some VB scripting and active directory-based looking-up.

Last edited by jallport; 03-28-2006 at 05:29 AM.
Reply With Quote