OSX won't automatically connect to WiFi
Reading this question reminded me that I had dealt with the same problem with my Mac awhile ago.

I fixed it by writing a shell script which was automatically called via launchd whenever /Library/Preferences/SystemConfiguration/ changes.

You'll have to configure a few things, mainly create a list of known SSIDs and passwords for the networks that you join.

You can find it here:
https://github.com/tjluoma/airport-autojoin