Hi there,
Trying to write a script that does the following
- Runs under the current logged on user
- Removes their FavoriteServers.sfl file (or even the whole parent directory)
- killall cfprefsd
- killall sharedfilelistd
- killall Finder
- Uses the SFLTOOL to add a new entry to the (now empty) FavoriteServers.sfl file
If I make the below code unix executable and run from the users desktop, it works a treat.
#!/bin/bash
rm ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.FavoriteServers.sfl
killall cfprefsd
killall sharedfilelistd
killall Finder
rm ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.FavoriteServers.sfl
sfltool add-item -n "OSAKA" com.apple.LSSharedFileList.FavoriteServers "cifs://OSAKA/"
killall Terminal
I think I will need something that actively targets the logged in user. I'm guessing as Casper is currently set to SSH as "HSCO.ADMIN" (local admin account) it will attempt to run all the commands targeting the hsco.admin user profile, instead of the user currently logged on. I tried something like the below. I think it's working to some extent as it kills / refreshes the Finder, but doesn't add anything to the FavoriteServers.sfl file.
#!/bin/bash
currentuser=$(/bin/ls -la /dev/console | /usr/bin/cut -d ' ' -f 4)
su -l $currentuser -c "rm -rf ~/Library/Application Support/com.apple.sharedfilelist/"
killall cfprefsd
killall sharedfilelistd
killall Finder
sfltool add-item -n "OSAKA" com.apple.LSSharedFileList.FavoriteServers "cifs://OSAKA/“
Any help would be much appreciated! :)