【问题标题】:How can I start a Program.app with LaunchDaemons (launchd)?如何使用 LaunchDaemons (launchd) 启动 Program.app?
【发布时间】:2013-08-08 19:58:06
【问题描述】:

我在文件夹中放置了以下 com.apple.test.plist 文件:

/System/Library/LaunchDaemons

<?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>Label</key>
        <string>com.apple.Spotlight</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

但由于某种原因,当我使用我的用户 todd 登录时 ApplicationTest.app 没有启动。

有什么想法吗?

【问题讨论】:

    标签: macos launchd


    【解决方案1】:

    密钥ProgramArguments 需要一个可执行文件,但您提供了一个应用程序包,这是一个美化目录。为了启动应用程序,您必须将 launchd 指向捆绑包中的可执行文件:

    <key>ProgramArguments</key>
    <array>
    <string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app/Contents/MacOS/ApplicationTest</string>
    </array>
    

    或者使用open(1) 命令运行应用程序:

    <key>ProgramArguments</key>
    <array>
    <string>/usr/bin/open</string>
    <string>-W</string>
    <string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
    </array>
    

    【讨论】:

      猜你喜欢
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-24
      • 1970-01-01
      • 2013-05-18
      • 2015-01-06
      • 1970-01-01
      相关资源
      最近更新 更多