Hi Everyone,
I am new to scripting so any help much appreciated.
I ran across a script to close an application modified it to close Sol.exe,
Worked great
Created separate scripts to close winmine, and freecell, etc
I tried my luck at creating an array (never done that before)to just have one script but only the first instance close can someone let me know what I am doing wrong.
This works
This closes sol.exe, and freecell.exe, but not winmine.exe
Thank You
RITec
I am new to scripting so any help much appreciated.
I ran across a script to close an application modified it to close Sol.exe,
Worked great
Created separate scripts to close winmine, and freecell, etc
I tried my luck at creating an array (never done that before)to just have one script but only the first instance close can someone let me know what I am doing wrong.
This works
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancecreationevent " _
& " within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
if objLatestProcess.TargetInstance.Name = "sol.exe" then
objLatestProcess.TargetInstance.Terminate
End if
Loop
This closes sol.exe, and freecell.exe, but not winmine.exe
Code:
'Attemp to stop or shut down local games
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancecreationevent " _
& " within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Tapps = Array("freecell.exe","sol.exe","winmine.exe")
For each tapp in tapps
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
if objLatestProcess.TargetInstance.Name = tapps then
objLatestProcess.TargetInstance.Terminate
End if
Loop
next
RITec