30

Is there a command that can be used from the command line to output a list of the printers installed and their location, if mapped, to a text file? Or perhaps a program that I can run from the command line that would do this?

28

In Windows XP use prntmngr:

PRNMNGR -l >> C:\printers.txt

In Windows Vista and beyond, use PowerShell:

get-WmiObject -class Win32_printer | ft name, systemName, shareName >> c:\printers.txt

Note: You MAY get an error if you attempt to write the file to C:\ on Vista+, depending on your rights, and how PowerShell was spawned.

For Windows 2000:

The PrnMngr.vbs file from XP (located in the /Windows/System32 folder) does work on Windows 2000. Just find and copy it over to the 2000 machine from an XP machine and run it with:

cscript prnmngr.vbs -l >> c:\printers.txt

I found it wouldn't run from my user's desktop for some reason, but when I copied the .VBS to the root of C: it ran fine.

  • Worked beautifully! – user35406 Apr 28 '10 at 4:56
15

I use:

wmic printer list brief

OR

wmic printer get name

This just shows a short list of printer attached to the system you run the command on. It will also show what computer a printer is connected to if there's a network printer.

You can also use this to get a very detailed list of configuration for each printer installed on a system:

wmic printer list full

To output it to a text file, append this to the end of the command:

 >>"[directory]\[filename].txt"

Example:

wmic printer list brief >> c:\users\admin\documents\printerlist.txt
  • This should be the accepted answer. – James Draper Dec 20 '17 at 16:37
4

Sometimes you don't want to use PS in win7 (I have an application that lets me do administrative work in the background on remote PCs, but it doesn't use powershell). The XP visual basic scripts mentioned can be found in the following folder for Win7:

C:\Windows\System32\Printing_Admin_Scripts\en-US
2

Starting with Windows 8 / Server 2012, there is a get-printer PowerShell cmdlet:

https://technet.microsoft.com/en-us/library/hh918358%28v=wps.630%29.aspx?f=255&MSPPError=-2147217396

  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Canadian Luke Aug 3 '16 at 20:04
1

Note: For Windows XP, be sure to change the default script host to CScript first

C:\CScript //H:CScript

otherwise you will get a message telling you to do so and your printers.txt file will be blank.

0

so this is my solution:

;******************
;ALLOCATING CONSOLE
;******************
; cmd calls hidden

global cPid
DetectHiddenWindows, on
Run, %comspec% /k ,,Hide UseErrorLevel,cPid
WinWait, ahk_pid %cPid%,, 1
DllCall("AttachConsole","uint",cPid)
hCon:=DllCall("CreateFile","str","CONOUT$","uint",0xC0000000,"uint",7,"uint",0,"uint",3,"uint",0,"uint",0)


;******* GET PRINTER NAMES **********

AllPrintersNameClearArray := strSplit(StrReplace(StrReplace(StrReplace(StrReplace("|" StrReplace(StrReplace(StrReplace(RunWaitOne("wmic printer get name"),"  ","")," `r",""),"`r",""),"|NAME`n",""),"`n","|"),"||","",All),"|","`n"),"`n")

RunWaitOne(command) {

    objShell := ComObjCreate("WScript.Shell")
    objExec := objShell.Exec(command)
    strStdOut := ""
    while, !objExec.StdOut.AtEndOfStream
    strStdOut := objExec.StdOut.ReadAll()
    return %strStdOut%
}

; **** Clean at the end *****

Finish:
DllCall("CloseHandle", "uint", hCon)
DllCall("FreeConsole")
Process, Close, %cPid%
ExitApp
return
0

Use Powershell.

[System.Drawing.Printing.PrinterSettings]::InstalledPrinters

  • Welcome to Super User. Can you say anything more than this? While I think this is technically an answer, it leaves a lot to the imagination and as such isn't a high-quality answer. – Twisty Impersonator Apr 17 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy