Posted on 09-20-2021 07:49 AM
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
Solved! Go to Solution.
Posted on 09-20-2021 09:04 AM
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
Posted on 09-20-2021 09:04 AM
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