Jump to content

stjw38

Members
  • Posts

    4
  • Joined

  • Last visited

stjw38's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. This is all beautiful. Thanks for all your help, guys. I think I've got what I needed.
  2. Beautiful! I downloaded Scriptomatic to check it out and it offers a lot of good stuff. I don't suppose either of you know if I can use it to generate code to add/remove printers, do you. I now I can shell out to rundll32 printui.dll,PrintUIEntry, but would prefer to use the same method as prnmngr.vbs which uses oPrinter.Put_(kFlagCreateOnly) and oPrinter.Delete_. I don't know how those translate to AutoIt. And... Thanks, guys, for your help. I've used the code example above to capture the information into an INI file.... Global $wbemFlagReturnImmediately = 0x10 Global $wbemFlagForwardOnly = 0x20 Global $colItems = "" Global $strComputer = @Computername Global $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2") Global $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly) ListPrinters() Func ListPrinters() If IsObj($colItems) then For $objItem In $colItems IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Device ID", $objItem.DeviceID) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Attributes", $objItem.Attributes) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Comments", $objItem.Comment) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Default Priority", $objItem.DefaultPriority) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Driver Name", $objItem.DriverName) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Location", $objItem.Location) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Port Name", $objItem.PortName) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Print Job Data Type", $objItem.PrintJobDataType) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Print Processor", $objItem.PrintProcessor) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Priority", $objItem.Priority) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Separator File", $objItem.SeparatorFile) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Server Name", $objItem.ServerName) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"Shared", $objItem.Shared) IniWrite(@ScriptDir & "Printers.ini",$objItem.DeviceID,"ShareName", $objItem.ShareName) ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop ;'$Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Printer" ) Endif EndFunc
  3. My biggest issue seems to be creating the object type. Below is the code I have so far for listing the printers, but I seem to have an issue with creating the object.... Dim $PrinterList, $PrinterCount ListPrinters(@Computername) Func ListPrinters($strServer) Local $Return dim $Printers dim $oService dim $oPrinter dim $iTotal $oPrinters = ObjCreate("Win32_Printer") $Printers = ObjCreate("Win32_Printer") $iTotal = 0 For $oPrinter in $Printers $iTotal = $iTotal + 1 ;MsgBox(0,"",L_Empty_Text) MsgBox(0,"",$strServer) MsgBox(0,"",$oPrinter.DeviceID) MsgBox(0,"",$oPrinter.ShareName) MsgBox(0,"",$oPrinter.DriverName) MsgBox(0,"",$oPrinter.PortName) MsgBox(0,"",$oPrinter.Comment) MsgBox(0,"",$oPrinter.Location) MsgBox(0,"",$oPrinter.SepFile) MsgBox(0,"",$oPrinter.PrintProcessor) MsgBox(0,"",$oPrinter.PrintJobDataType) MsgBox(0,"",$oPrinter.Parameters) MsgBox(0,"",String($oPrinter.Attributes)) MsgBox(0,"",String($oPrinter.Priority)) MsgBox(0,"",String($oPrinter.DefaultPriority)) next EndFunc Results in "List Printer.au3 (22) : ==> Variable must be of type "Object".: For $oPrinter in $Printers For $oPrinter in $Printers^ ERROR"
  4. I have a working knowledge of AutoIt for the most part, but my experience with vbscript is very limited. I'd love to have the functions in prnmngr.vbs converted to AutoIt code so that I can build a GUI around it. If someone could help me isolate and convert one of the functions so I can get a solid idea of how to do it, I'd appreciate it a lot. And, I'm sure there are other administrators that would appreciate the converted script as well. I'm speaking of the version of prnmngr.vbs included with Win 7. Thanks, Joe
×
×
  • Create New...