Skip to main content
Solved

Restarting OneDrive After Loading New PLIST

  • September 20, 2021
  • 1 reply
  • 24 views

Forum|alt.badge.img+4

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

 

Best answer by jmandler

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

 

 

1 reply

Forum|alt.badge.img+8
  • Contributor
  • Answer
  • September 20, 2021

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