James Anderson
James Anderson

Reputation: 566

Preventing an application closing using AppleScript

I have created a script with AppleScript and have exported it as an application. How can I force the application to stay open constantly so the user cannot force-quit it: i.e. how can I open the application again on force-quit?

Thanks

Upvotes: 0

Views: 496

Answers (1)

Lri
Lri

Reputation: 27613

You could save a plist like this as ~/Library/LaunchAgents/test.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>test</string>
    <key>Program</key>
    <string>/Applications/Untitled.app/Contents/MacOS/applet</string>
    <key>RunOnLoad</key>
    <true/>
</dict>
</plist>

It can be loaded with launchctl load ~/Library/LaunchAgents/test.plist or by logging out and back in.

Upvotes: 1

Related Questions