Code:
$prog1 = 'calc.exe'
$prog2 = 'notepad'
SHELL "%SystemRoot%\system32\"+$prog1
While @ERROR <> 0
EnumProc($prog1)
Sleep 1
Loop
sleep 5
;; Now you may want to set a sleep offset depending on
;; whether the condition exists where the program, even
;; though it may be started, needs to wait a few secs
;; before kicking off the other...
SHELL "%SystemRoot%\system32\"+$prog2
Function EnumProc($exe)
Dim $winmgmts, $ExecQuery, $Proc, $ID, $GetObject
$winmgmts = "winmgmts:{impersonationLevel=impersonate}!//" + @wksta
$ExecQuery = "select * from Win32_Process where Name='" + "$exe'"
$GetObject = GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Proc in $GetObject
$ID = $Proc.ProcessID
$EnumProc = $ID + "|" + $EnumProc
Next
$EnumProc = Left($EnumProc,Len($EnumProc)-1)
$GetObject = ''
EndFunction
Calc.exe launches, WHen checking Task Manager there is a process called, "calc.exe".
I launch the code from a command prompt and I do get a '1' displayed after calc.exe launches.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5