Check if helper app is running from the trash

My app has a helper app which should quit if the main app is moved to the trash. How do I do that?

App.ExecutableFile.Parent.Parent.Parent does not change if the app is moved to the trash.

The I tried to use ProcessMBS but this grabbed some random process:

dim AppFolderitemFromProcess as FolderItem
dim theProcesses as processMBS
dim myCode as string = app.ExecutableFile.Parent.Parent.Parent.getBundleID
theProcesses = new processMBS
theProcesses.GetFirstProcess
do
if theProcesses.BundleID = myCode then
AppFolderitemFromProcess = theProcesses.Path
exit do
end if
loop Until not theProcesses.GetNextProcess

The result was /usr/sbin/universalaccessd which doesn’t make any sense at all.

Any ideas?

Do you have Einhugur? I use FileSystemWatcher in FileFreeze to watch a specific file (the one you set up). The plugin provides event based notifications when a file changes.

Maybe it might be better at noticing when the parent app has been moved to the trash?

I have the Einhugur plugins. I’ve used the equivalent in the MBS plugins but the name of the function escapes me at the moment. Not a bad idea. A user is unlikely to have multiple versions of my app on the computer.

It doesn’t change, indeed, but FolderItem.exists property becomes false. At least, you know it has been moved.

Clever idea. I’ll check that.