Examine the building to determine where the bats are getting in and out. Bats are most active at dusk, so go outside just after sunset and watch for bats entering and exiting the building. Pay special attention to eaves, vents, chimneys and other areas that may provide easy access points.
Create exclusion screens that will allow bats to get out but prevent them from re-entering. Nail or staple small squares of screening over each entrance point, attaching the screen at the top while leaving it loose at the bottom. This will create a flap that can be pushed outward from the inside, but cannot be pushed inward.
Allow between one and two weeks to ensure that all the bats have left the premises. Then remove the exclusion screens and seal the gaps permanently with caulk or insulation.
Provide the bats with alternative roosting locations. Small backyard bat houses can be purchased cheaply from most home supply stores and can be installed in your yard to encourage bats to continue playing their useful role in the ecosystem while staying out of occupied buildings.