我一直在尝试以不同的用户身份运行应用程序。
尝试 1
sudo -u otheruser open /Applications/TextEdit.app启动应用程序,但它使用当前用户,而不是otheruser。
尝试2
login username并su - otheruser成功登录为otheruser,不同的用户活动监控器弹出,但类似open /Applications/TextEdit.app回报的错误LSOpenURLsWithRole() failed with error -10810 for the file /Applications/TextEdit.app.
尝试 3
sudo su - otheruser -c /Applications/TextEdit.app/Contents/MacOS/TextEdit似乎启动了该应用程序(它出现在由otheruser启动的 Activity Monitor 下)但是当停靠栏图标无限期地弹跳时会出现此错误:_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
问题
那么……我如何以不同的用户身份运行应用程序?