Forum Discussion
tristaanogre
8 years agoEsteemed Contributor
Change your code to the following:
function KillProcess(App){
var process;
process = Sys.WaitProcess(App, 10000);
// Checks whether the process is closed
if (process.Exists)
// Terminates the process
{
process.Terminate();
}
}
When detecting existence, it's best to use the appropriate "Wait" method... in this case, WaitProcess will look for the process, in my example, for up to 10 seconds. If the process returns within those 10 seconds, Exists is true. Otherwise, a stub object is returned with Exists as false.