I'm getting a really frustrating error that sometimes comes up and sometimes it runs through without a problem. My code is:
function killProcesses(processes) { // A string array of process names.
for (i = 0; i < processes.length; i++) {
var process = Sys.WaitProcess(processes[i])
if (process.Exists) { // Sometimes the script will crash right here
process.Terminate()
}
}
Since I made the function I have always passed the exact same process names in, sometimes they are started others they aren't, that's never been a problem. But other times it will crash while running and tell me Object doesn't support this property or method
. Like I said, this function and the line that calls it have never been changed, so I don't understand why only sometimes it fails.
I've gotten this in other parts of my scripts before, so I wonder if it might be related or there's just something in general wrong with my system. What really baffles me is that Exists
should always exist on everything, so why is it sometimes just not there?