I have a problem with my app to copy/delete a plist file in "/Library/LaunchAgents/" to control the auto-start function on checking/unchecking a checkbox.
I made an installer which has a "open file" action in "posti开发者_Python百科nstall actions". After install, the app is started successfully, but when I check the checkbox and enter my admin password to enable "auto-start" for all the users, the auto start .plist file is not copied to /Library/LauchAgents/ . If I kill the app then re-open the app manually, and then check the auto start option, the file can be copied to the folder successfully.
Here is the AppleScript i used for coping files to "/Library/LauchAgents/". I'm sure the sourcepath and the destinpath are right.
do shell script "cp '<sourcepath>' '<destinpath>'" with administrator privilege
Here are the error messages i got in Console:
9/30/11 11:12:18.217 AM authorizationhost: SFBuiltinEntitled: Installer.app is not entitled for system.install.app-store-software
9/30/11 11:12:18.219 AM com.apple.SecurityServer: Failed to authorize right 'system.install.app-store-software' by client '/System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/installd' [2042] for authorization created by '/System/Library/CoreServices/Installer.app' [2033]
9/30/11 11:12:18.277 AM installd: PackageKit:
----- Begin install -----
9/30/11 11:12:19.977 AM MyAppDemo: awakeFromNib()
9/30/11 11:12:20.007 AM installd: Installed "My Application Package" ()
9/30/11 11:12:20.035 AM installd: PackageKit:
----- End install -----
The correct code is:
do shell script "cp '<sourcepath>' '<destinpath>'" with administrator privileges
Notice how privileges has an 's' on the end. Your script must be having errors when it's run because of the misspelling.
精彩评论