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
| Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Do
If Not IsProcessRunning("Calc.exe") Then
WshShell.Run "Calc.exe",1,True
wscript.sleep 1000
end if
Loop
'********************************************************************************************
Function IsProcessRunning(pProcessName)
'Fonction fera une requête WMI pour déterminer si un processus processName
'est en cours d'exécution sur l'ordinateur local. Renvoie True si détecté.
Dim objWMIService
Dim strWMIQuery
strWMIQuery = "Select * From Win32_Process Where name Like '" & pProcessName & "'"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Exécutez la requête
If (objWMIService.ExecQuery(strWMIQuery).Count > 0) Then
IsProcessRunning = True
Else
IsProcessRunning = False
End If
End Function
'********************************************************************************************** |
Partager