There are various pest-repelling devices which operate on a high-pitched frequency which animals can't stand. I have one aimed at the rabbits which would otherwise happily munch their way through my veggie garden. The instructions said it would take a little while to deal to them, and it did, but I don't have rabbits eating my greens now, although there are plenty further afield. I reckon any squirrel used to the good life in the attic would similarly be forced to move out!