Page 1 sur 1

[R] commande powershell dans Autoit  

Posté : jeu. 21 sept. 2023 15:39
par ludoo
Bonjour,
est-il possible de convertir ce script PS en Autoit ou comment le faire executer ?

Code : Tout sélectionner

$InfoDvd = @()
$InfoDvd +=  Get-CimInstance -ClassName Win32_PnPEntity -Filter "PNPClass = 'USBDevice'"
$Scanneronline= $InfoDvd.Caption
if ($Scanneronline -eq "EPSON Utility")
{
Write-Host "scanner present" -ForegroundColor Green
}
else
{
Write-Host "scanner no present" -ForegroundColor Red
}
merci de votre aide

Re: [..] commande powershell dans Autoit

Posté : sam. 23 sept. 2023 16:54
par mikell
Faudrait essayer ça
Mais j'ai pas pu tester (dans Win32_PnPEntity la propriété PNPClass n'existe pas sous Windows 7) alors bon ... Image

Local $query = "select * from Win32_PnPEntity where PNPClass = 'USBDevice'"
Local $objWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $colItems = $objWMI.ExecQuery($query, "WQL", 0x10 + 0x20)
Local $test = 0
If IsObj($colItems) Then
   For $objItem In $colItems
      If $objItem.Caption = "EPSON Utility" Then
         $test = 1
         Exitloop
      EndIf
   Next
EndIf
Msgbox(0,"", ($test = 1) ? "scanner present" : "scanner not present")

Re: [..] commande powershell dans Autoit

Posté : lun. 25 sept. 2023 09:56
par ludoo
merci , nickel .