Omegis Posted July 4, 2006 Posted July 4, 2006 Hi, i have tries to convert this part of script: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Printer WHERE PrinterStatus = 1" _ & "OR PrinterStatus = 2") If colInstalledPrinters.Count = 0 Then Wscript.Echo "All printers are functioning correctly." Else For Each objPrinter in colInstalledPrinters Wscript.Echo "Printer " & objprinter.Name & " is not responding." Next End If but i a bit stuck on the last part with the "for each" here is the modified (but not complated) script that i have done: $strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery("Select * from Win32_Printer Where PrinterStatus = '1' or PrinterStatus = '2'") If $colInstalledPrinters.Count = 0 Then MsgBox(0,"","All printers are functioning correctly.") Else For Each objPrinter in colInstalledPrinters;need to convert to autoit Wscript.Echo "Printer " & objprinter.Name & " is not responding.";need to convert to autoit Next;need to convert to autoit EndIf any advise given with be well apritioated !
tonedeaf Posted July 4, 2006 Posted July 4, 2006 VB Code: For Each objPrinter in colInstalledPrinters Wscript.Echo "Printer " & objprinter.Name & " is not responding." Next would convert to: For $objPrinter in $colInstalledPrinters Msgbox(0, "", "Printer " & $objPrinter.Name & " is not responding.") Next
Omegis Posted July 4, 2006 Author Posted July 4, 2006 VB Code: For Each objPrinter in colInstalledPrinters Wscript.Echo "Printer " & objprinter.Name & " is not responding." Next would convert to: For $objPrinter in $colInstalledPrinters Msgbox(0, "", "Printer " & $objPrinter.Name & " is not responding.") Next Thanks ...
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