VBS Script - Can this script please be editted to close after it triggers?
This VBS script below detects when Outlook.exe is loaded and then triggers another script to load.
It currently works perfectly but... if outlook is closed and then re-opened the script runs again.
Could someone please advise how it could be modified to close after it detects outlook and launches the script.
Somehow get it out of the loop?
Thanks in advance
Set objShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("Select * from __InstanceCreationEvent " _
& " Within 1 Where TargetInstance ISA 'Win32_Process' AND " & _
"TargetInstance.Name = 'Outlook.exe'")
Do While True
Set objProcess = colMonitoredProcesses.NextEvent
objShell.Run "cscript.exe C:\Scripts\Test.vbs"