If it's your app, then it could write a file, kind of like a flag, and then delete the file when the app closes. If it's another program, maybe you could use a batch file that does the same thing.