Restarting OneDrive After Loading New PLIST

gwhaley262
New Contributor II

Hello,

We're updating our OneDrive configurations. I have it covered with placing the new PLIST on systems and quitting OneDrive. But I'd like to be able to relaunch it as the user who's currently logged in. Is there a script or process I could use for this?

Thanks

 

1 ACCEPTED SOLUTION

jmandler
New Contributor III

Set a variable for the current logged in user: 

loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

 Use that variable to run a launch command as that user:

 

sudo -u $loggedInUser <command>

 

For OneDrive, it should be:

 

sudo -u $loggedInUser /Applications/OneDrive.app/Contents/MacOS/OneDrive

 

 

View solution in original post

1 REPLY 1

jmandler
New Contributor III

Set a variable for the current logged in user: 

loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

 Use that variable to run a launch command as that user:

 

sudo -u $loggedInUser <command>

 

For OneDrive, it should be:

 

sudo -u $loggedInUser /Applications/OneDrive.app/Contents/MacOS/OneDrive

 

 

View solution in original post