Windows 10: I am trying to change printer properties via python code, but constantly getting Access...

Discus and support I am trying to change printer properties via python code, but constantly getting Access... in Windows 10 Software and Apps to solve the problem; As Administrator I am running this python script on my own computer: import win32printimport win32con# Get the default printer namedefault_printer_name... Discussion in 'Windows 10 Software and Apps' started by Martin Orator, Mar 17, 2023.

  1. I am trying to change printer properties via python code, but constantly getting Access...


    As Administrator I am running this python script on my own computer: import win32printimport win32con# Get the default printer namedefault_printer_name = win32print.GetDefaultPrinter# Open the printer with the given nameprinter_handle = win32print.OpenPrinterdefault_printer_name# Get the current printer settingsproperties = win32print.GetPrinterprinter_handle, 2devmode = properties['pDevMode']# Change the printer orientation to landscapedevmode.Orientation = win32con.DMORIENT_LANDSCAPEdevmode.Scale = 1# Set the new printer settingswin32print.SetPrinterprinter_handle, 2, properties, 0#

    :)
     
    Martin Orator, Mar 17, 2023
    #1

  2. I am trying to change printer properties via python code, but constantly getting Access Denied error.

    As Administrator I am running this python script on my own computer:

    import win32print

    import win32con

    # Get the default printer name

    default_printer_name = win32print.GetDefaultPrinter()

    # Open the printer with the given name

    printer_handle = win32print.OpenPrinter(default_printer_name)

    # Get the current printer settings

    properties = win32print.GetPrinter(printer_handle, 2)

    devmode = properties['pDevMode']

    # Change the printer orientation to landscape

    devmode.Orientation = win32con.DMORIENT_LANDSCAPE

    devmode.Scale = 1

    # Set the new printer settings

    win32print.SetPrinter(printer_handle, 2, properties, 0)

    # Close the printer handle

    win32print.ClosePrinter(printer_handle)

    Getting this response: win32print.SetPrinter(printer_handle, 2, properties, 0)

    pywintypes.error: (5, 'SetPrinter', 'Access is denied.')
     
    Martin Orator, Mar 18, 2023
    #2
  3. Printer Properties

    Hi Paul,

    Welcome to Microsoft Community and thank you for your interest in Windows 10.

    I suggest you to follow the below steps how to go to printer settings.

    • In the search box type “control panel”.
    • Click on “device and printers”.
    • Then you can right click on your printer and then click on properties, change accordingly.
    I suggest you to follow the below article if you face any issues with printer and check if it helps.

    Fix printer connection and printing problems in Windows - Microsoft Support

    Hope this information was helpful and do let us know if you need further assistance. We will be glad to assist.
     
    Karthicka_R, Mar 18, 2023
    #3
  4. I am trying to change printer properties via python code, but constantly getting Access...

    Can't change printer preferences in Windows 10

    Hi Chris,

    Thank you for posting your query in Microsoft community.

    I apologize for the inconvenience caused. We are glad to help you.


    • What exactly happens when you try to go into printer driver settings from Control Panel?
    I suggest you to try the steps given below and check if it helps:

    Step 1:


    • Type change default printer and hit
      enter.


    • Check whether you are able to change the preferences and properties from here.

    Step 2:


    • Type printers and scanners and hit
      enter.


    • Check whether you are able to change the preferences and properties from here.

    Hope this information helps. Do contact us for further queries. We will be happy to assist you.

    Regards,

    Jenith
     
    Jenith_James, Mar 18, 2023
    #4
Thema:

I am trying to change printer properties via python code, but constantly getting Access...

Loading...
  1. I am trying to change printer properties via python code, but constantly getting Access... - Similar Threads - trying change printer

  2. When i try to change the language, I constantly get an error

    in Windows 10 Gaming
    When i try to change the language, I constantly get an error: My default language is set to Romanian Moldova . My region settings are set for Moldova . I find British English being much easier to use on a device, but i can't seem to be able to set it at the main language. Under the language name on the LANGUAGE tab in the settings it...
  3. When i try to change the language, I constantly get an error

    in Windows 10 Software and Apps
    When i try to change the language, I constantly get an error: My default language is set to Romanian Moldova . My region settings are set for Moldova . I find British English being much easier to use on a device, but i can't seem to be able to set it at the main language. Under the language name on the LANGUAGE tab in the settings it...
  4. I am trying to connect via Chat

    in Windows 10 Gaming
    I am trying to connect via Chat: I would like to chat with Microsoft support. https://answers.microsoft.com/en-us/windows/forum/all/i-am-trying-to-connect-via-chat/126ac43f-f671-4985-af79-5be2167c8b42
  5. I am trying to connect via Chat

    in Windows 10 Customization
    I am trying to connect via Chat: I would like to chat with Microsoft support. https://answers.microsoft.com/en-us/windows/forum/all/i-am-trying-to-connect-via-chat/126ac43f-f671-4985-af79-5be2167c8b42
  6. I am trying to connect via Chat

    in Windows 10 Software and Apps
    I am trying to connect via Chat: I would like to chat with Microsoft support. https://answers.microsoft.com/en-us/windows/forum/all/i-am-trying-to-connect-via-chat/126ac43f-f671-4985-af79-5be2167c8b42
  7. I am trying to change printer properties via python code, but constantly getting Access...

    in Windows 10 Gaming
    I am trying to change printer properties via python code, but constantly getting Access...: As Administrator I am running this python script on my own computer: import win32printimport win32con# Get the default printer namedefault_printer_name = win32print.GetDefaultPrinter# Open the printer with the given nameprinter_handle =...
  8. I am trying to change printer properties via python code, but constantly getting Access...

    in AntiVirus, Firewalls and System Security
    I am trying to change printer properties via python code, but constantly getting Access...: As Administrator I am running this python script on my own computer: import win32printimport win32con# Get the default printer namedefault_printer_name = win32print.GetDefaultPrinter# Open the printer with the given nameprinter_handle =...
  9. I am trying to load a script through python

    in Windows 10 Customization
    I am trying to load a script through python: I am trying to load a script through python and it says 'fatal error' with 'Failed to execute script- pc-optimizer' I have looked everywhere with no info,...
  10. Simple python code

    in Windows 10 Customization
    Simple python code: Hi microsoft, I have simple python 3.x code script.py: import os os.popen"pip install pillow".read when I try to call this using "python script.py" I allways get yellow color of texts in command line after the script finishes. Is that only my bug? Thank you...