3

These dialogs can be manually accessed via the control panel, but I just want to access them via the command line or at least via a shortcut file that will open them directly. I am quite simply getting very frustrated with the control panel and the modern Windows settings program fighting over each other.

enter image description here

I was able to figure out to create a shortcut file by right-clicking a print and then choosing "create a shortcut", but running this shortcut opens the "print que dialog".

The control panel as well as other places in Windows are reliably able to open every printer's "preferences" and "properties" dialogs, so there must be some kind of interface, something similar to these.

Jan Doggen
  • 4,657
Ralf_Reddings
  • 445
  • 2
  • 9

3 Answers3

3

This is an exceptionally broad set of tasks so there is no simplistic answer.

As administrator you can do what you wish from a command line. Such as open the print Management panel for controlling most of the print system settings. enter image description here enter image description here
Much of print managements scripts are VBS files so not CMD nor Powershell but faster CScript and can thus be used with web interface based HTA as used in older internet Explorer or now Edge. But that is not an easy route to follow as a user.
enter image description here

' prndrvr.vbs - driver script for WMI on Windows 
'     used to add, delete, and list drivers.
'
' Usage:
' prndrvr [-adlx?] [-m model][-v version][-e environment][-s server]
'         [-u user name][-w password][-h file path][-i inf file]
'
' Example:
' prndrvr -a -m "driver" -v 3 -e "Windows NT x86"
' prndrvr -d -m "driver" -v 3 -e "Windows x64"
' prndrvr -d -m "d

enter image description here Add a paper size add a printer restrict other users etc. Likewise there is the command line PRINTUI.exe for print management by command line. So you can save printer settings make temporary changes and reset to as was before.

enter image description here

Answer

One way to see the current printers quickly is use a shortcut to wrap the prnmngr.vbs find and pause commands in a call via cmd

%ComSpec% /r Cscript C:\windows\system32\Printing_Admin_scripts\en-us\prnmngr.vbs -l | find "Printer name" & pause

enter image description here

So for example fastest is from the listed printers use a command shortcut such as:

printui  /n "Microsoft Print to PDF" /p

enter image description here

OR use other options (test them via the command line first) enter image description here

K J
  • 1,248
2

I have tested these solutions and can confirm they are working.

To open the "printer properties" dialog for a specific printer:

 # Define the printer name
 $printerName = "PDF-XChange Standard"

Open the printer properties dialog

Start-Process "rundll32.exe" -ArgumentList "printui.dll,PrintUIEntry /n "$printerName" /p"

To open the "printer preferences" dialog for a specific printer

 # Open the Printing Preferences dialog
 Start-Process "rundll32.exe" -ArgumentList "printui.dll,PrintUIEntry /n `"$printerName`" /e"

To get the correct name for the printer in question use

 # Get all installed printers
 $printers = Get-WmiObject -Query "SELECT * FROM Win32_Printer"
 # Display printer names
 $printers | ForEach-Object { Write-Output $_.Name }
Ralf_Reddings
  • 445
  • 2
  • 9
1

This is based on Ralf Reddings answer.

This script will generate a shortcut file to open the properties dialog for a specific printer. The printer I have chosen is named Microsoft Print to PDF. You can change the name to suit your preferences.

Once you run the script, a shortcut will appear in your directory. This shortcut can be accessed without entering powershell.

<#
.SYNOPSIS
   Generates a shortcut to printer properties for a specific printer.
#>

$printername = 'Microsoft Print to PDF'

$path = Get-Location

$WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Path\myprinter.lnk") $Shortcut.TargetPath = "rundll32.exe" $Shortcut.Arguments = "printui.dll,PrintUIEntry /n &quot;$printerName" /p" $Shortcut.Save()