Exclusion is the best policy in preventing bats from gaining entrance into buildings. Due to their size bats can squeeze through cracks as narrow as an inch wide. Some of their preferred entrances are in older frame structures where boards are loose or have shrunk. They may also enter houses through loose vents, eaves, spaces around water pipes, electrical outlets, corrugated roofing, doors or windows.
If you are certain the noises in your attic are being made by bats, wait for them to leave, then seal the entrances before they return. Unfortunately, you will need to do the work at night when bats depart for their nightly feeding forays. It is also wise to do this in the fall after the young have learned to fly. Or, wait until winter when many bats have migrated south.
Caulking cracks is most effective if applied during dry weather when cracks are the widest.
Weather-stripping, which seals spaces around doors and windows, is also effective in repairing cracks.
Never handle a bat that appears sick or wounded. It is possible the bat could have rabies.
Bats can be helpful in your neighborhood because they consume a lot
of insects and usually do not pose a health threat to humans.