none
Enable A4 and Duplex and avoid the same for Barcode printers RRS feed

  • Question

  • Hi,
    I do not have enough scripting expirience but hope somene can help me.
    I have task to make a hiden script which will enable A4 and Duplex for locally USB connected printers in our environment and avoid the same for barcode printers.

    Script should do something like this:

    Check PRINTER EXISTS?
    No - STOP SCRIPT
    Yes- --->
    Check PRINTER IS "ZEBRA Printer" or some other like DYMO Barcode Printer?
    Yes - Do not execute for this printer
    No - --->
    Check A4 and DUPLEX are set?
    Yes - STOP SCRIPT
    No - --->
    ENABLE A4 and DUPLEX

    To enable A4 and Duplex I can use:

    :: set default paper size to A4 and Duplex on all local printers for current user
    setprinter.exe "" 9 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4"
    setprinter.exe "" 9 "pdevmode=dmduplex=2,dmCollate=1,dmFields=|duplex collate"

    :: set default paper size to A4 and Duplex  on all local printers for global default
    setprinter.exe "" 8 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4"
    setprinter.exe "" 8 "pdevmode=dmduplex=2,dmCollate=1,dmFields=|duplex collate"
    But how to check is printer "barcode" printer and are A4 and duplex already enabled I do not have idea.
    Script should work for Stadard User (do not have local admin permissions)

    Any idea? :-/
    • Moved by Bill_Stewart Friday, July 27, 2018 6:32 PM This is not "scripts on demand"
    Wednesday, April 25, 2018 12:50 PM

All replies

  • Not scripting question .  "setprinter" is a system utility and  not a script. 

    To detect barcode printers you will need to check the model and manufacturer.

    Local printers cannot be configured by non-admins.

    Post your issue in the printing forum for specific print configuration help.

    Please carefully review the following links to set your expectation for posting in  technical forums.

    This Forum is for Scripting Question Rather than script requests

    Script Gallery.

    Script Center

    Learn PowerShell  

    Script requests
    PowerShell Documentation

    PowerShell Style Guidelines

    From a Bill Stewart summary of useful forum links:


    \_(ツ)_/


    • Edited by jrv Wednesday, April 25, 2018 12:57 PM
    Wednesday, April 25, 2018 12:56 PM
  • Hi,
    I do not have enough scripting expirience but hope somene can help me.
    I have task to make a hiden script which will enable A4 and Duplex for locally USB connected printers in our environment and avoid the same for barcode printers.

    Script should do something like this:

    Check PRINTER EXISTS?
    No - STOP SCRIPT
    Yes- --->
    Check PRINTER IS "ZEBRA Printer" or some other like DYMO Barcode Printer?
    Yes - Do not execute for this printer
    No - --->
    Check A4 and DUPLEX are set?
    Yes - STOP SCRIPT
    No - --->
    ENABLE A4 and DUPLEX

    To enable A4 and Duplex I could maybe use:

    :: set default paper size to A4 and Duplex on all local printers for current user
    setprinter.exe "" 9 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4"
    setprinter.exe "" 9 "pdevmode=dmduplex=2,dmCollate=1,dmFields=|duplex collate"

    :: set default paper size to A4 and Duplex  on all local printers for global default
    setprinter.exe "" 8 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4"
    setprinter.exe "" 8 "pdevmode=dmduplex=2,dmCollate=1,dmFields=|duplex collate"

    But how to check is printer "barcode" printer and are A4 and duplex already enabled I do not have idea.
    Script should work for Stadard User (do not have local admin permissions)

    Any idea? :-/
    • Merged by jrv Wednesday, April 25, 2018 8:18 PM DUPLICATE
    Wednesday, April 25, 2018 3:28 PM
  • Enable A4 and Duplex and avoid the same for Barcode printers

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Wednesday, April 25, 2018 3:30 PM
  • You can use this to get all locally attached printers:

    get-printer |where{$_.Type -eq 'Local'} | select *

    Then filter by printer name or driver name to exclude all known  barcode printers.


    \_(ツ)_/

    Wednesday, April 25, 2018 8:20 PM
  • Ok, I tried something like this:

    $Printers = get-printer | where{$_.Type -eq 'Local'} | Where-Object {($_.DriverName -like 'HP Universal*') -or ($_.DriverName -like 'HP Color*') -or($_.DriverName -like 'HP Laser*') -or($_.DriverName -like 'Samsung*') -or($_.DriverName -like 'Lexmark*')}

    foreach ($Printer in $Printers) {

        $argList = """$($Printer.DriverName)"" " + 9 + " ""pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4, dmduplex=2,dmCollate=1,dmFields=|duplex collate"""
        write-host $argList
        $a = Start-Process -FilePath "Location-of-setprinter-exe-file\setprinter.exe" -ArgumentList '"" 9 "pdevmode=dmPaperSize=9, dmPaperLength=2970, dmPaperWidth=2100, dmFormName=A4, dmduplex=2,dmCollate=1,dmFields=|duplex collate"'}

    I want to filter only local connected printers with printer driver name for which I am sure I want to enable A4 and Duplex and exclude ZEBRA and DYMO barcode printers. What I can see this will be applied for ZEBRA and DYMO barcode printers.

    Any idea where I am doing mistake?

       

    • Edited by Ante666 Wednesday, May 2, 2018 1:15 PM made mistake
    Wednesday, May 2, 2018 1:11 PM