Jump to content

Search the Community

Showing results for tags 'print server'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Use these functions to capture and restore windows network printers. This script was used in a Win XP/7 environment running 2008 R2 servers. Global Const $PrinterList = (@DesktopDir & "printerlist.csv") Func PrinterBackup() Local $csvfile ConsoleWrite($PrinterList & @LF) $csvfile = FileOpen($PrinterList, 10) ; Pull default printer and write it to the first line of the file $objWMI = ObjGet("winmgmts:.rootCIMV2") $colPrinters = $objWMI.ExecQuery("SELECT * FROM Win32_Printer", "WQL", 0x10 + 0x20) If IsObj($colPrinters) Then For $objPrinter In $colPrinters If $objPrinter.Default = "True" And $objPrinter.Network = "-1" Then ConsoleWrite("Writing printer " & $objPrinter.Name & @CR) Sleep(500) FileWriteLine($PrinterList, $objPrinter.Name & @CR) EndIf Next EndIf ; Then grab the rest of the printers, if any $objWMI = ObjGet("winmgmts:.rootCIMV2") $colPrinters = $objWMI.ExecQuery("SELECT * FROM Win32_Printer", "WQL", 0x10 + 0x20) If IsObj($colPrinters) Then For $objPrinter In $colPrinters If $objPrinter.Network = "-1" And $objPrinter.Default = ("") Then ConsoleWrite("Writing printer " & $objPrinter.Name & @CR) Sleep(500) FileWriteLine($PrinterList, $objPrinter.Name & @CR) EndIf Next EndIf FileClose($csvfile) If FileExists($PrinterList) = 0 Then TrayItemSetState($ItemPrinterRestore, $TRAY_DISABLE) ElseIf FileExists($PrinterList) <> 0 Then TrayItemSetState($ItemPrinterRestore, $TRAY_ENABLE) EndIf EndFunc ;==>PrinterBackup Use this function to restore printers.... Global Const $PrinterList = (@DesktopDir & "printerlist.csv") Func PrinterRestore() Local $PrinterArray[1], $x, $csvfile If FileExists($PrinterList) Then $csvfile = FileReadLine($PrinterList) If Not $csvfile = ("") Then _FileReadToArray($PrinterList, $PrinterArray) For $x = 1 To 1 RunWait(@ComSpec & " /c " & "rundll32 printui.dll,PrintUIEntry /in /n" & $PrinterArray[$x], "", @SW_HIDE) RunWait(@ComSpec & " /c " & "rundll32 printui.dll,PrintUIEntry /y /n" & $PrinterArray[$x], "", @SW_HIDE) Next For $x = 2 To $PrinterArray[0] RunWait(@ComSpec & " /c " & "rundll32 printui.dll,PrintUIEntry /in /n" & $PrinterArray[$x], "", @SW_HIDE) Next EndIf EndIf EndFunc ;==>PrinterRestore
×
×
  • Create New...