30
10
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?
30
10
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.
18
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
1This should be the accepted answer. – James Draper – 2017-12-20T16:37:07.400
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 – 2016-08-03T20:04:37.5471
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. – I say Reinstate Monica – 2019-04-17T23:24:07.543
Worked beautifully! – None – 2010-04-28T04:56:54.163