Macos MAC OS Sierra-在启动时运行应用程序?

Macos MAC OS Sierra-在启动时运行应用程序?,macos,plist,startup,macos-sierra,launchd,Macos,Plist,Startup,Macos Sierra,Launchd,我正在尝试将应用程序(*.app)设置为在MAC OS Sierra中启动时运行。我知道必须将plist添加到以下文件夹中 /图书馆/启动代理 我用下面的代码创建了一个plist。每次加载MAC OS时,它都需要在启动时以管理员身份运行。但它不起作用。应用程序不会在启动时启动。如何使应用程序在启动时工作 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//

我正在尝试将应用程序(*.app)设置为在MAC OS Sierra中启动时运行。我知道必须将plist添加到以下文件夹中

/图书馆/启动代理

我用下面的代码创建了一个plist。每次加载MAC OS时,它都需要在启动时以管理员身份运行。但它不起作用。应用程序不会在启动时启动。如何使应用程序在启动时工作

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.myapp.startup</string>
    <key>Program</key>
    <string>/Applications/myapp.app/Contents/MacOS/myapp</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>LaunchOnlyOnce</key>        
    <true/>
    <key>StandardOutPath</key>
    <string>${installdir}/startup.stdout</string>
    <key>StandardErrorPath</key>
    <string>${installdir}/startup.stderr</string>
    <key>UserName</key>
    <string>admin</string>
    <key>GroupName</key>
    <string>admin</string>
    <key>InitGroups</key>
    <true/>
  </dict>
</plist>

标签
com.myapp.startup
节目
/Applications/myapp.app/Contents/MacOS/myapp
运行负荷
持久连接
发射台
标准门诊
${installdir}/startup.stdout
标准错误路径
${installdir}/startup.stderr
用户名
管理员
组名
管理员
初始组

您需要使用launchctl向launchd注册文件。您可能会在专用的Apple Stack Exchange站点上找到更多帮助,例如有一个快速指南。您可能还希望将其创建为一个启动守护进程。看