Hi Chris
Tanya is correct - you need to use the 'wait' methods with Exists. I've attached a simple example below, which determines whether the Windows Calculator process is running. It simply logs a message to the log file as to whether it is or not and returns a Boolean true or false accordingly...
function isCalculatorOpen()
{
var isOpen;
if (Sys.waitProcess("calc", 1000).Exists)
{
Log.Message("Process Exists.");
isOpen = true;
}
else
{
Log.Message("Process Does Not Exist.");
isOpen = false;
}
return isOpen;
}
Hope this is helpful.
Addendum: Perhaps an explanation would also be helpful...
When you try to access the 'Exists' property on a process or a control that does actually exist, the system is able to access that property, which would obviously be true. However, as in your case, when the process itself doesn't exist, it's properties don't actually exist either, so trying to reference the 'Exists' property will fail.
The 'Wait*' methods catch this error and what actually happens is that when a process or control doesn't exist, the 'Wait*' method generates a dummy or stub object with only one property, the 'Exists' property, which will be set to false, thus enabling your code to carry on without failing.
Regards
Stephen.