How do I write a script to disconnect all network drives?
-
16-10-2019 - |
Question
I work in a windows environment with active directory. Just logging out doesn't disconnect (unbind) the network drives. I need something more forceful, and faster than shutting down and restarting. Because if my mac awakes in another network without connection to the windows shares it gives me the spinning beach ball of death.
Solution
Are these shares automounted?
You could use AppleScript, or even bash quite effectively to do this using a Log Out Hook (or running manually):
tell application "Finder"
if ((count of disks) > 1) then
set drives to disks
repeat with drive in drives
eject drive
end repeat
end if
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange