Can't run add login item via Casper Remote

cmickb
New Contributor

I'm having trouble pushing a script with Casper Remote. We are trying to add OneDrive added to the list of login items for all of our students. The script I'm using works perfect if I run it locally through terminal. When I run it with Casper Remote I get the error:
36:140: execution error: An error of type -10810 has occurred. (-10810)

Any ideas?

#!/bin/sh

sudo osascript -e 'tell application "System Events" to make login item at end with properties {path:"Applications/OneDrive.app", hidden:true , name:"OneDrive"}'

echo 0
1 REPLY 1

mm2270
Legendary Contributor III

When you run any script over Casper Remote, its not running the script as the logged in user. Its running it as root or as the Casper service account. The osascript command in your script only affects the logged in user. Therefore, check out threads on "How to run a script as the current user" for an answer.