Sign in to follow this  
Followers 0
Omegis

VBScript to Autoit3 Beta

3 posts in this topic

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 !

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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 ...

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