[python-win32] determine the default printer from RDP

john johnf at jfcomputer.com
Thu Feb 27 15:23:13 EST 2020


I have discovered a solution to the issue.
import wmi
c = wmi.WMI()
  wql = "SELECT * FROM WIN32_PRINTER WHERE Default = TRUE"

  for printer in c.query(wql):
         selectedPrinter = printer.caption

where selectPrinter is the device name of the printer.

Hope this helps somebody in the future.

Johnf

On 2/26/20 8:48 AM, Terry Davis wrote:
> Hi John,
>
> In the Windows RDP client, under "Show Options" -> "Local Resources" 
> -> section "Local devices and resources" is "Printers" checked?
>
> I haven't tried what you're referring to, but perhaps that setting is 
> relevant to your problem?
>
> - Terry
>
> On Tue, Feb 25, 2020 at 5:51 PM john <johnf at jfcomputer.com 
> <mailto:johnf at jfcomputer.com>> wrote:
>
>     Hi,
>
>     I need a way to determine the default printer (on the users
>     computer) from a RDP session.
>
>     The user logs on to a RDP session and
>     win32print.GetDefaultPrinter() returns a blank.  That makes sense
>     on the RDP session because there aren't any default printers.  RDP
>     printing is directed to the default printer on the users desktop.
>
>     Is there a way to get the default printer from the RDP session.
>
>     Johnf
>     _______________________________________________
>     python-win32 mailing list
>     python-win32 at python.org <mailto:python-win32 at python.org>
>     https://mail.python.org/mailman/listinfo/python-win32
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20200227/5a69f824/attachment.html>


More information about the python-win32 mailing list