Bonjour,
Je voudrais savoir comment reduire le code suivant :
' Requete WMI pour obtenir la liste des process en cours
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strComputer)
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process")
Affichage = "<center><b><u>Liste des processus</b></u><p>"
For Each Proc in colProcessList
If Proc.Name = "amqsvc.exe" Then AMQSVC=1
If Proc.Name = "amqzmuc0.exe" Then AMQZMUC0=1
If Proc.Name = "amqzxma0.exe" Then AMQZXMA0=1
If Proc.Name = "amqzfuma.exe" Then AMQZFUMA=1
If Proc.Name = "amqzlaa0.exe" Then AMQZLAA0=1
If Proc.Name = "amqzmgr0.exe" Then AMQZMGR0=1
If Proc.Name = "amqzmur0.exe" Then AMQZMUR0=1
If Proc.Name = "amqrrmfa.exe" Then AMQRRMFA=1
If Proc.Name = "amqzdmaa.exe" Then AMQZDMAA=1
If Proc.Name = "amqpcsea.exe" Then AMQPCSEA=1
If Proc.Name = "amqxssvn.exe" Then AMQXSSVN=1
If Proc.Name = "runmqchi.exe" Then RUNMQCHI=1
If Proc.Name = "runmqlsr.exe" Then RUNMQLSR=1
Next
If AMQSVC = 1 Then
Affichage = Affichage & "<font color=green>amqsvc.exe</font> <br>"
Else
Affichage = Affichage & "<font color=red>amqsvc.exe</font><br>"
End If
If AMQZMUC0 = 1 Then
Affichage = Affichage & "<font color=green>amqzmuc0.exe</font> <br>"
Else
Affichage = Affichage & "<font color=red>amqzmuc0.exe</font><br>"
End If
Et ainsi de suite pour tous les processus présent dans la boucle.
Aujourd’hui mon script marche mais n’est pas très esthétique et pas pratique en cas de rajout d’autre processus.
J’aimerais pouvoir les mettre dans une variable puis boucler dessus mais je sais pas comment faire.
Sa doit être surement très con mais je sèche là.
Merci de vos suggestion
Edité le 26/07/2007 à 11:23