ViciousXUSMC Posted June 17, 2015 Posted June 17, 2015 Where can I find $iportnumber for already installed printers?I am used to the IP and Name when installing but not designating a port# so not sure what values I should be using. Also for both display config and enumerate printers using array display is there a way to have a header on the data so you know the name of the values you are looking at?
jguinch Posted June 21, 2015 Author Posted June 21, 2015 To get the port number, you can use this :; #FUNCTION# ==================================================================================================================== ; Name ..........: _EnumTCPIPPrinterPort ; Description ...: Enumerate all TCP/IP printer ports ; Syntax ........: _EnumTCPIPPrinterPort([$sPortName = ""]) ; Parameters ....: $sPortName - Name of the port to retrieve informations. ; Defaut "" returns informations for all ports. ; Return values .: Success - Returns an array containing all informations : ; $array[0][0] = 1st Port name ; $array[0][1] = 1st Port Host Address ; $array[0][2] = 1st Port Host Number ; $array[X][0] = Xth Port name ; [ ... ] ; Failure - Returns 0 and sets @eror to non-zero ; =============================================================================================================================== Func _EnumTCPIPPrinterPort($sPortName = "") Local $aResult[1][10], $filter, $i = 0 Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 If $sPortName <> "" Then $filter = " Where Name = '" & $sPortName & "'" Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If NOT IsObj($objWMIService) Then Return SetError(1, 0, 0) $colPorts = $objWMIService.ExecQuery ("Select * from Win32_TCPIPPrinterPort" & $filter, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If NOT IsObj($colPorts) Then SetError(2, 0, 0) For $oPort In $colPorts $i += 1 Redim $aResult[ $i][3] $aResult[$i - 1][0] = $oPort.Name $aResult[$i - 1][1] = $oPort.HostAddress $aResult[$i - 1][2] = $oPort.PortNumber Next If $i = 0 Then Return 0 Return $aResult EndFuncFor the header of the displayed array, just use $sHeader in the _ArrayDisplay :$aPrintersConfig = _EnumPrinterConfiguration() _ArrayDisplay($aPrintersConfig, "_EnumPrinterConfiguration", "", 0, Default, "BitsPerPel|Caption|Collate|Color|Copies|Description|DeviceName|DisplayFlags|DisplayFrequency|DitherType|DriverVersion|Duplex|FormName|HorizontalResolution|ICMIntent|ICMMethod|LogPixels|MediaType|Name|Orientation|PaperLength|PaperSize|PaperWidth|PelsHeight|PelsWidth|PrintQuality|Scale|SettingID|SpecificationVersion|TTOption|VerticalResolution|XResolution|YResolution") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
ila Posted November 14, 2015 Posted November 14, 2015 (edited) please help me.how can i add printer,like "\\192.168.1.252\Brother HL-2130 series"? Edited November 14, 2015 by ila
colombeen Posted November 15, 2015 Posted November 15, 2015 1 feature is missing and it would be so easy to add it... managing remote printers
Cyberonimo Posted March 22, 2016 Posted March 22, 2016 Hi Really your programs are very useful do you have some to add local print server
mLipok Posted March 22, 2016 Posted March 22, 2016 Added to Wiki: https://www.autoitscript.com/wiki/User_Defined_Functions#Hardware Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
jguinch Posted March 24, 2016 Author Posted March 24, 2016 Thanks mLipok for the link on the wiki. @Cyberonimo, I don't understand what you want (add local print server ???). If you want to add a local printer, just use_AddPrinter and specify a local port. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
jguinch Posted July 27, 2016 Author Posted July 27, 2016 I'm happy to share the new version of my PrintMgr UDF. All functions have been renamed, prefixed by _PrintMgr. New features : - CancelAllJobs - EnumPrinter - Pause - PrinterExists - PrintTestPage - RenamePrinter - Resume Please ask if any question Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
mLipok Posted July 28, 2016 Posted July 28, 2016 Please upload this UDF here:https://www.autoitscript.com/forum/files/category/12-hardware/ Thanks. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
jguinch Posted July 28, 2016 Author Posted July 28, 2016 Done Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
mLipok Posted July 28, 2016 Posted July 28, 2016 Nice ICO Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
Kaimberex Posted August 19, 2016 Posted August 19, 2016 (edited) I am using the below example script and this is what error returns: #Include <Array.au3> $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) "C:\AutoIt\Include\PrintMgr.au3" (206) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aRet[$iCount] = $oPrinter.Name ^ ERROR Edited August 19, 2016 by Kaimberex
jguinch Posted August 19, 2016 Author Posted August 19, 2016 @Kaimberex : I just updated my code, can you download the file again and retry ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Kaimberex Posted August 22, 2016 Posted August 22, 2016 On 8/19/2016 at 3:27 PM, jguinch said: @Kaimberex : I just updated my code, can you download the file again and retry ? I was able to get it to work another way for now I will update to new version and let you know. I do however have a question about _PrintMgr_SetDefaultPrinter. This function only seems to work on a Local printer not a network installed printer. I am trying to set the below printer as a default and it returns 0 when setting the printer as default. I can get it to return 1 on locally installed printers just not network printers. I have tried using the FQDN of the printer. I have also just tried the ShareName. Neither works.
jguinch Posted August 24, 2016 Author Posted August 24, 2016 There was an error in the WMI query, fixed now (please download the updated file) Yes, you have to use the share name for remote shared printers (I added a remarks in the function header) argumentum 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Kaimberex Posted August 25, 2016 Posted August 25, 2016 (edited) On 8/24/2016 at 9:51 AM, jguinch said: There was an error in the WMI query, fixed now (please download the updated file) Yes, you have to use the share name for remote shared printers (I added a remarks in the function header) This still does not work. I have used the share name and the path to the network printer i.e \\Servername\Printer Edited August 25, 2016 by Kaimberex
Kaimberex Posted August 25, 2016 Posted August 25, 2016 1 minute ago, Kaimberex said: This still does not work. I have used the share name and the path to the network printer i.e \\Servername\Printer I got it to work, but you have to use the FQDN of the print server i.e \\Servername.domain.com\Printer name. argumentum 1
Joboy2k Posted October 20, 2016 Posted October 20, 2016 Hi, i have been trying to get the _Printmgr_PrinterExists func to work but it couldn't get it to work, i took alook at the code and the only way i could get it to work is by adding this line into the function $sPrinterName = StringReplace($sPrinterName, "\", "\\") so now the function looks like this and this is how i can get it to work for me at least Func _PrintMgr_RemovePrinter($sPrinterName) $sPrinterName = StringReplace($sPrinterName, "\", "\\") Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If NOT IsObj($oWMIService) Then Return SetError(1, 0, 0) Local $oPrinters = $oWMIService.ExecQuery ("Select * from Win32_Printer where DeviceID = '" & $sPrinterName & "'") If NOT IsObj($oPrinters) Then Return SetError(1, 0, 0) For $oPrinter in $oPrinters $oPrinter.Delete_() Next Return ( _Printmgr_PrinterExists($sPrinterName) ? 0 : 1) EndFunc ; ==> _PrintMgr_RemovePrinter hope this helps, or if i have messed something else up by doing this please let me know as i am an amateur and still have a very basic understanding.
jguinch Posted October 24, 2016 Author Posted October 24, 2016 @joboy2k : Thanks for your feedback. You are right. It was an error that I did not take the time to correct. It's done now. Joboy2k 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
jguinch Posted January 31, 2017 Author Posted January 31, 2017 (edited) Update : added functions to create/remove LPR printer ports. Edited January 31, 2017 by jguinch mLipok 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now