Sign in to follow this  
Followers 0
Ghost21

Getting Printer list from servers

2 posts in this topic

I'm trying to get the printers from each server and list them in a treeview. The problem is for some reason when I do the orginal

$aPrintQueues = _AD_ListPrintQueues()

The data in the second col. isn't sorted which is a problem and isn't. It isn't a problem if someone can show me how to search just the

server that the printer is on and not all of them for a duplicat. As Duplicate can be on more then one machine but not on the same server. ???

Func _AD_ListPrinter()
    $AD_Printer_TreeViewItem = ""
    $SamePrintServer = ""
    $b = ""
    _AD_Open()
    $aPrintQueues = _AD_ListPrintQueues()
    For $i = 1 To $aPrintQueues[0][0]
        $a = $aPrintQueues[$i][1]
        If $b <> $a Then
            $b = $a
            $PrintServer = StringSplit($aPrintQueues[$i][1], ".")
            $AD_PrintServer = StringUpper($PrintServer[1])
            $hItem = _GUICtrlTreeView_FindItem($TreeView2, $AD_PrintServer, True, 0)
            If $hItem <> "" Then
            Else
                _GUICtrlTreeView_Add($TreeView2, $AD_PrintServer, StringStripWS($AD_PrintServer, 3))
                msgbox(0,"Print Server",$AD_PrintServer)
            EndIf
            $hItem = ""
            $Printers = _AD_ListPrintQueues($PrintServer[1])
            For $ii = 1 To $Printers[0][0]
                $AD_Printer = $Printers[$ii][0]
                $hItem = _GUICtrlTreeView_FindItem($TreeView2, $AD_PrintServer, True, 0)
                If $hItem <> "" Then
                    _GUICtrlTreeView_AddChild($TreeView2, $hItem, StringStripWS($AD_Printer, 3))
                        msgbox(0,"Printer",$AD_Printer)
                Else
                EndIf
                $AD_Printer = ""
            Next
            $ii = ""
            $Printers = ""
        Else
        EndIf
        $Percent = Round((100 * $aPrintQueues[0][0]) / 100)
        $Percent = _Min(_Max(1, $Percent), 99)
        GUICtrlSetData($Progress1, $Percent)
        $AD_PrintServer = ""
        $hItem = ""
    Next
    _AD_Close()
    GUICtrlSetData($Progress1, 0)
EndFunc   ;==>_AD_ListPrinter

HELP !!!

Share this post


Link to post
Share on other sites



If you know on which spool server the printer queue is defined then you can pass the server name as a parameter to _AD_ListPrintQueues.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0