简体   繁体   English

使用非管理员权限从Mac .pkg启动新安装的应用程序

[英]Launch newly-installed application from Mac .pkg with non-admin privileges

I'm building a Mac installer package (.pkg) using pkgbuild and productbuild. 我正在使用pkgbuild和productbuild构建Mac安装程序包(.pkg)。 I'm able to get my application bundle installed, but I'd like to launch it at the end of the install. 我可以安装我的应用程序捆绑包,但是我想在安装结束时启动它。 I added 我加了

open /Applications/MyAppName

to the postinstall script. 后安装脚本。 This launches my app, but it has different permissions or otherwise differs from an app that the user manually launches after completing the install. 这将启动我的应用程序,但是它具有不同的权限,或者与用户在完成安装后手动启动的应用程序不同。 The installer requires admin privileges since it's copying the app bundle to /Applications, but this appears to interfere with the functionality of the app when launched by the postinstall script. 由于安装程序会将应用程序捆绑包复制到/ Applications,因此需要管理员权限,但这似乎在由后安装脚本启动时干扰了应用程序的功能。 One example is that an applescript command in my app that's supposed to copy a file with admin privileges fails. 一个例子是我的应用程序中的一个AppleScript命令(该命令应使用管理员权限复制文件)失败。

Is there some way to launch an app with the user's normal privileges? 有什么方法可以使用用户的正常权限启动应用程序?

You can try 你可以试试

sudo -u "$USER" open /Applications/MyAppName

This will run your application as specified user. 这将以指定用户身份运行您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM