32

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?

8 Answers 8

29

In Windows XP use prntmngr:

PRNMNGR -l >> C:\printers.txt

In Windows XP SP3 Vista and beyond (you need to install powershell v1 manually) , 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.

2
  • Worked beautifully!
    – user35406
    Commented Apr 28, 2010 at 4:56
  • In windows XP SP3 you can manually install Powershell c1 and it will also work there.
    – Wasif
    Commented Sep 20, 2020 at 15:45
22

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
1
  • 1
    This should be the accepted answer. Commented Dec 20, 2017 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
3

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

1
  • 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. Commented Aug 3, 2016 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

In PowerShell ISE you can run this to see a list of all installed printers.

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

See the dot.net PrinterSettings.InstalledPrinters Property for more info.

1
  • 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. Commented Apr 17, 2019 at 23:24
0

Since WMI is being depreciated, I will use CIM in powershell:

Get-CIMInstance CIM_Printer | Format-Table Name,SystemName,ShareName >>printers.txt
0

So this is my solution (in AutoHotKey):

;******************
;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
2
  • What language is this? Please write more about how this works.
    – stomy
    Commented Jun 25, 2020 at 19:55
  • 1
    @stomy this is an Autohotkey script.
    – Wasif
    Commented Sep 20, 2020 at 15:47

You must log in to answer this question.