13

Microsoft Windows XP comes with a VBS script to manage local and network printers from the command line:

To Get the default printer details from command line:

cscript C:\windows\system32\prnmngr.vbs -g

To Get the list of printers added to the system from Windows command line:

cscript C:\windows\system32\prnmngr.vbs -l

Is there any equivalent commands for Windows 7? I just need to get the default printer details and get the list of printers attached to the system.

7 Answers 7

16

In Windows 7 these same scripts are found in

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

List of all printers names and shows default one (You can get more details read documentation)

wmic printer get name,default

If you want output to file use:

wmic printer get name,default > D:\catalog\file.txt

Availability

The wmic command is an external command that is available in the below Microsoft operating systems as wmic.exe.

Windows XP professional
Windows 2003
Windows Vista
Windows 7
Windows 8
Windows 10
1
  • 2
    This worked for me in Windows 10: for /f "tokens=2 delims==" %A in ('wmic.exe printer WHERE default^=TRUE get name /VALUE') do set "default_printer=%~A" May 12, 2020 at 21:46
2

On Windows 10, the scripts are found in the same place as Windows 7. Execute the following command to display the default printer.

cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g

Note if there is no default printer, the script will return nothing

1

i found mine in the sideXside folder...

C:\windows\winsxs\x86_microsoft-windows-p..inscripts.resources_31bf3856ad364e35_6.1.7600.16385_en-us_0e83b619ada3e7ed\

i ran the following: cscript C:\windows\winsxs\x86_microsoft-windows-p..inscripts.resources_31bf3856ad364e35_6.1.7600.16385_en-us_0e83b619ada3e7ed\prnmngr.vbs -g

it worked.

1

To list active printer components on Windows 8.1:

c:>cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -l | findstr "Printer name"

enter image description here

0

To remove printer in Windows 8.1:

cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -d -p "Printer name"

I had trouble with a printer not showing in devices/printers so unable to remove it, although it was there when I pressed file > print in firefox. It was also stopping me from using the printer name for the actual installation (it bugged me having to append _1 at the end of the default printer!"

0

Using a batch file (no VBScript files):

@echo off

::Get printer CLSID
for /f %%a in ('reg query HKCU\Printers\Defaults') do (set regkey=%%a)
::Get printer name from the previous CLSID

for /f "tokens=3*" %%a in ('reg query %regkey%') do (set printername=%%a %%b)
echo Printer name is: %printername%

I wish that could help you

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.