Boucle vbs d’attente de fin de process msiexec
Avec MDT, j’avais des setup.exe qui lancé des MSI. J’avais besoin d’être certain que tous les MSI soient terminés avant de passer à l’application suivante.
Voici le script d’attente de fin de process msiexec (< 2 process msiexec)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
DIM strComputer,strProcess strComputer = "." ' local computer strProcess = "msiexec" ' Check if Calculator is running on specified computer (. = local computer) For i = 0 To 600 ' 10 Min wscript.sleep 3000 if is2ProcessRunning(strComputer,strProcess) = False then i = 99999 End If next ' Function to check if a process is running function is2ProcessRunning(byval strComputer,byval strProcessName) Dim objWMIService, strWMIQuery CountProcess = 0 strObject = "winmgmts://" & strServer For Each Process in GetObject( strObject ).InstancesOf( "win32_process" ) If Instr(UCase(Process.name),UCase(strProcess)) <> 0 Then CountProcess = CountProcess + 1 Next If CountProcess > 1 Then is2ProcessRunning = true Else is2ProcessRunning = False End If end function |
Le vbs : Download
Cet article n'a pas été revu depuis la publication.
Cet article a été créé par david le 26 décembre 2016.
Laisser un commentaire