Jump to content

get the windows printers in control panel


Recommended Posts

I wrote a script that calls the list of printers two different ways.  One is using the built in Windows prnmngr.vbs the other is using a UDF called compinfo.

#include <File.au3>
#Include <compinfo.au3>

$ThisPC = @ComputerName


DirCreate(@DesktopDir & "\Gathered Information\" & $ThisPC)
$DeskDriveFile = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\" & @UserName & " Mapped Drives.txt")
$DeskPrnFile = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\" & @UserName & " Printers.txt")
$DeskPrnFile2 = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\" & @UserName & " Printers2.txt")
$DeskStartFile = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\Common Startup.txt")
$DeskDesktopFile = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\Common Desktop.txt")
$DeskBiosFile = (@DesktopDir & "\Gathered Information\" & $ThisPC & "\SystemBiosInfo.txt")

Run(@ComSpec & ' /k net use > ' & '"' & $DeskDriveFile & '"', 'C:\', @SW_HIDE)
Run(@ComSpec & ' /k cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -l > ' & '"' & $DeskPrnFile & '"', 'C:\', @SW_HIDE)
$StartupAllUsr = _FileListToArray(@StartupCommonDir)
_FileWriteFromArray($DeskStartFile, $StartupAllUsr)
$DesktopAllUsr = _FileListToArray(@DesktopCommonDir)
_FileWriteFromArray($DeskDesktopFile, $DesktopAllUsr)

Dim $Print
_ComputerGetPrinters($Print)


For $i = 1 To $Print[0][0] Step 1
    FileWriteLine($DeskPrnFile2,"Name: " & $Print[$i][0] & @CRLF & _
            "Description: " & $Print[$i][4] & @CRLF & _
            "Comment: " & $Print[$i][9] & @CRLF & _
            "DeviceID: " & $Print[$i][28] & @CRLF & _
            "DriverName: " & $Print[$i][31] & @CRLF & _
            "PortName: " & $Print[$i][59] & @CRLF & _
            "ServerName: " & $Print[$i][72] & @CRLF & _
            "Shared: " & $Print[$i][73] & @CRLF & _
            "ShareName: " & $Print[$i][74] & @CRLF & _
            "SystemName: " & $Print[$i][80] & @CRLF & _
            "WorkOffline: " & $Print[$i][84] & @CRLF & @CRLF)
Next


Dim $SystemProduct

_ComputerGetSystemProduct($SystemProduct)


For $i = 1 To $SystemProduct[0][0] Step 1
    FileWriteLine($DeskBiosFile, "Name: " & $SystemProduct[$i][0] & @CRLF & _
            "Identifying Number: " & $SystemProduct[$i][1] & @CRLF & _
            "SKU Number: " & $SystemProduct[$i][2] & @CRLF & _
            "UUID: " & $SystemProduct[$i][3] & @CRLF & _
            "Description: " & $SystemProduct[$i][4] & @CRLF & _
            "Vendor: " & $SystemProduct[$i][5] & @CRLF & _
            "Version: " & $SystemProduct[$i][6])
Next









$Final = MsgBox(4, "Black Magic Automation","Information Gathered!, Also Capture Files for Desktop & Startup?")
If $Final = 7 Then
    Exit
Else
    DirCopy(@DesktopCommonDir, @DesktopDir & "\Gathered Information\" & $ThisPC & "\Common Desktop\", 1)
    DirCopy(@StartupCommonDir, @DesktopDir & "\Gathered Information\" & $ThisPC & "\Common Startup\", 1)
EndIf

 

Link to comment
Share on other sites

ViciusXUSMC, thank you for your reply.

jguinch, thanks for your reply too.

Forgive-me to not add this information in the post:

a] I don't have administratives permission in the machine;
b] I have one thousand of printers in gui (above) and net get it...
c] not all printers are instaled in the machine, it is a list of all available printers (the list is my target)

So sorry for my mistake, if can I run any script, it is very easy...


 

Edited by Luigi

Visit my repository

Link to comment
Share on other sites

Bert, your tip is (very) interesting. I will study it. Thank you.

About the code:
I can write this code to get the information:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

If Not WinActive("Propriedades de PrinterName em LANNETWORK") Then WinActivate("Propriedades de PrinterName em LANNETWORK")
Global $hGui = WinGetHandle("Propriedades de PrinterName em LANNETWORK")
Global $hListView = ControlGetHandle("Propriedades de PrinterName em LANNETWORK", "", "[Class:SysListView32]")
ConsoleWrite("$hListView[ " & $hListView & " ]" & @LF)


Global $a_list[_GUICtrlListView_GetItemCount($hListView)]

For $ii = 0 To _GUICtrlListView_GetItemCount($hListView) - 1
    For $jj = 0 To 3
        If $jj = 0 Or $jj = 2 Then ConsoleWrite(_GUICtrlListView_GetItemText($hListView, $ii, $jj) & @TAB)
    Next
    ConsoleWrite(@LF)
Next

 

Visit my repository

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...