?
Solved

Find where a particular printer is installed

Posted on 2007-07-29
8
Medium Priority
?
317 Views
Last Modified: 2010-03-05
Hi,

I want to find all machines in the list which is installed with a particular printer.Is there a way to get this.

Regards
Sharath
0
Comment
Question by:bsharath
  • 4
  • 4
8 Comments
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19587781
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script require "Computers.txt" file on C: drive root from where it will read computer names.
:: * Enclose printer name in double quotes if it contains any space
:: * Successful run will generate "PrintersReport.txt" file on C: drive root
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.

:: *** SCRIPT START ***
@Echo Off
SetLocal EnableDelayedExpansion
IF [%1]==[] Goto :CmdHelp

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\PrintersReport.txt DEL /F /Q C:\PrintersReport.txt
SET PrnName=
FOR /F "delims=*" %%c IN ('Type C:\Computers.txt') Do (
    Echo Processing: %%c
      FOR /F "delims=#" %%Q IN ("%1") DO SET PrnName=%%~Q
      WMIC /Node:"%%c" Printer WHERE "Name='!PrnName!'" GET NAME /Value | Find /I "Name=" >NUL
      IF NOT ErrorLevel 1 (
      Echo !PrnName! found on %%c >>PrintersReport.txt) Else (
      Echo !PrnName! does not found on %%c >>PrintersReport.txt)
)
Goto EndScript
:CmdHelp
Echo.
Echo Usage:
Echo       BatchFileName.cmd ^<"PrinterNameToSearch"^>
Echo Example:
Echo       SearchPrn.cmd "HP4200_A4"
Echo.
Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: Batch Script End
0
 
LVL 11

Author Comment

by:bsharath
ID: 19587798
i GET THIS.


C:\>"SEARCH WHERE ALL A PRINTER IS INSTALLED.CMD" "HC-1F"
Processing: dev-chen-nas01
No Instance(s) Available.
Processing: INEXCHANGE1
No Instance(s) Available.
Processing: IN-EX-CL01
No Instance(s) Available.
Processing: IN-EX-CL02
No Instance(s) Available.
Processing: DEV-CHEN-SRV400
Node - DEV-CHEN-SRV400
ERROR:
Code = 0x80070005
Description = Access is denied.
Facility = Win32
Processing: DEV-CHEN-MRD100
No Instance(s) Available.
C:\>

THIS IS THE COMMAND
>"SEARCH WHERE ALL A PRINTER IS INSTALLED.CMD" "HC-1F"
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19587816
Above result is normal check 'PrintersReport.txt' file.
"No Instance(s) Available." means printer not found on that machine.
Following error appears because you do not have administrative access on 'DEV-CHEN-SRV400' machine.
Processing: DEV-CHEN-SRV400
Node - DEV-CHEN-SRV400
ERROR:
Code = 0x80070005
Description = Access is denied.
Facility = Win32
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Author Comment

by:bsharath
ID: 19587847
I have this in the report file.
HC-1F does not found on dev-chen-nas01
HC-1F does not found on INEXCHANGE1
HC-1F does not found on IN-EX-CL01
HC-1F does not found on IN-EX-CL02
HC-1F does not found on DEV-CHEN-SRV400
HC-1F does not found on DEV-CHEN-MRD100

In dev-chen-mrd100 i have this printer installed but it shows as not found
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19587882
Apply following commands and post the results:

Click on Start -> Run -> Cmd.exe
WMIC /Node:"dev-chen-mrd100" Printer GET Name
0
 
LVL 11

Author Comment

by:bsharath
ID: 19587887
I get this.

C:\>WMIC /Node:"dev-chen-mrd100" Printer GET Name
Name
Send To OneNote 2007 (from DEV-CHEN-SRV400) in session 0
Send To OneNote 2007
\\dev-chen-srv10\HC-1F
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19587981
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script require "Computers.txt" file on C: drive root from where it will read computer names.
:: * Enclose printer name in double quotes if it contains any space
:: * Successful run will generate "PrintersReport.txt" file on C: drive root
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.

:: *** SCRIPT START ***
@Echo Off
SetLocal EnableDelayedExpansion
IF [%1]==[] Goto :CmdHelp

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\PrintersReport.txt DEL /F /Q C:\PrintersReport.txt
SET PrnName=
FOR /F "delims=*" %%c IN ('Type C:\Computers.txt') Do (
    Echo Processing: %%c
      FOR /F "delims=#" %%Q IN ("%1") DO SET PrnName=%%~Q
      WMIC /Node:"%%c" Printer WHERE "Name='!PrnName!' OR ShareName='!PrnName!'" GET NAME /Value | Find /I "Name=" >NUL
      IF NOT ErrorLevel 1 (
      Echo !PrnName! found on %%c >>PrintersReport.txt) Else (
      Echo !PrnName! does not found on %%c >>PrintersReport.txt)
)
Goto EndScript
:CmdHelp
Echo.
Echo Usage:
Echo       BatchFileName.cmd ^<"PrinterNameToSearch"^>
Echo Example:
Echo       SearchPrn.cmd "HP4200_A4"
Echo.
Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: Batch Script End
0
 
LVL 11

Author Comment

by:bsharath
ID: 19588064
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip is around source server preparation. No migration is an easy migration, there is a…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question