Krista Lane was awakened by a noise in the middle of the night. Something was flying around her bedroom.

At first, Lane said, she thought a bird had gotten into her Massachusetts home, but then she remembered the time. The winged intruder, she realized, had to be a bat.

Lane, 68, had never dealt with a bat inside her home before and there was only one thought on her mind: “I have to get this thing out of here.”

She found a plastic dust pan in a nearby closet, and used that to stun the bat, scoop it up without touching it and deposit it far from her house. “I don’t know what you’re supposed to use,” she said. “In my adrenaline-driven state, I just grabbed what I saw and did what I could to capture it and get it outside.”

But while Lane acted the way many people would if they woke up to find a bat in their home, she made a common a mistake: getting rid of it. Because bats can be a source of human rabies and Lane didn’t know whether she had been exposed to the bat while she was asleep, that meant she needed rabies shots.

“If you’ve had contact with a wild animal, and you don’t have the wild animal for it to be tested, then the protocol is for the human to get vaccinated for rabies,” said Fran Hutchins, director of Bat Conservation International’s Bracken Cave Preserve in Texas.

The ideal situation if you may have been exposed to a bat is to capture it alive, so it can be tested for rabies. Here’s why, and what Hutchins and other experts say you need to know about dealing with a bat that makes an unexpected visit to your home.

How do bats get inside?

If a bat finds its way into your living area, “the first thing that people should think about is the possibility of having a colony,” said Dana Limpert, the eastern regional ecologist for the Wildlife and Heritage Service with the Maryland Department of Natural Resources. In some areas where bats’ preferred natural habitats — hollow cavities of dead and dying trees known as snags, for one — have become scarce, the animals have adapted to man-made structures, Limpert said. “Unfortunately, attics look like a big hollow tree to them.”

These colonies typically consist of female bats raising their pups. “When the juveniles are learning how to fly and forage for food, they’re just like any other child or kid, they will get lost and confused,” Hutchins said. “They may end up getting in from the attic space into the living space.”

Other possibilities: A bat could accidentally fly into a home through an open, unscreened window or door. It could be brought inside by a dog or cat. Or, it could crawl through a tiny hole. “If you can stick your pinkie finger into a hole, a bat could squeeze into that space,” Hutchins said.

Basic home maintenance, such as plugging holes and making sure screens are intact, is a key part of bat-proofing, experts said. But they emphasized that finding a bat inside your living space is not common.

“They don’t want to be there anymore than we want them to be there,” Hutchins said, “and basically, at that point, everybody’s trying to get out of the house, including the bat.”

Limpert agreed. “They really have no interest in people,” she said. “They just are making a mistake that may be fatal, unfortunately, for them.”

What should I do if I find a bat in my house?

Because rabies is commonly transmitted through saliva, the way to handle a bat visit will depend on whether you think there is any chance someone in your household has been bitten, scratched or exposed to the animal’s saliva in some other fashion, said Rick Reynolds, a wildlife biologist with the Virginia Department of Wildlife Resources. If so, you should try to capture the animal, so it can be tested.

If you are trying to capture a bat yourself, do not handle the animal with bare hands. “They’re not out to bite people, but they will defend themselves if cornered,” Limpert said.

Experts suggest waiting for the bat to land and then placing a small container, such as a cardboard box, over it. Slide a piece of cardboard under the container to trap the bat inside. The container should be secure, but have air holes.

In the event that someone in your household or a pet has a confirmed exposure or if you are unsure, experts recommend calling your local health department for advice about the next steps. To avoid potential complications with pets, make sure their rabies vaccinations are up to date.

If you are “110 percent certain that no one’s been exposed to the bat,” Reynolds said, it’s best to help it find a way out of your house.

Do not chase the bat around with a broom, which could injure the animal, or worse, kill it, Hutchins said. Some bat species are legally protected, and there may be penalties for killing one. What’s more, bats are a vital part of natural ecosystems and play important roles in insect pest consumption, plant pollination and seed dispersal, according to Bat Conservation International.

Instead of chasing it, turn off ceiling fans and lights, and open exterior doors and windows so the bat can leave on its own, Hutchins said. If possible, close off routes to adjacent rooms in the house.

If that approach does not work, you might have to capture and release the bat. After capturing it as explained above, wait until nightfall to let the bat go. Look for an elevated surface upon which to place the container (bats need to drop from a high point to start flying), and tip the container on its side so the animal can crawl out.

Bat Conservation International provides an online, step-by-step guide for capturing and releasing bats. If you don’t feel comfortable handling this on your own, contact your local wildlife agency or a permitted wildlife control service. If you have a colony of bats, experts generally recommend bringing in professionals to help with removal.

What's the possibility I will need rabies shots?

Rabies in humans has become very rare in the United States, in part because of the successful rabies vaccination program for dogs. While the most common way Americans now contract the virus is through contact with bats, the chances of a bat being sick with rabies are slim. The estimated incidence of rabies in the wild bat population is “less than one half of one percent,” Limpert said.

Rabies, however, is a fatal disease. “Since the outcome is death or severe neurological deficits, we are extremely cautious and err on the side of giving people prophylaxis, even if it’s probably unnecessary,” said Marc Siegel, an associate professor of medicine in the Division of Infectious Diseases at George Washington University.

For example, you might receive shots if a bat was flying around while you were asleep, Siegel said. “Puncture sites from bat bites are hard to find.” And, Reynolds noted, people who aren’t able to communicate well, such as young children, the elderly and those with disabilities, may not be able to communicate or even be aware that they have been bitten or scratched by a bat.

If you do need to be vaccinated against rabies and are remembering that painful shots used to be administered in the abdomen or buttocks, there is a bit of good news. The shots are now injected in the arm, though the four inoculations must follow a strict schedule, usually over a two-week period.

If there is a bat near you, but you’re conscious and know there has not been contact, you probably won’t need rabies shots, Siegel said. He added that transmission through aerosols produced by an infected bat flying around you is an “extremely low risk.”

If you do know you have been bitten or scratched, the Centers for Disease Control and Prevention recommends washing the wound thoroughly with soap and water and seeking medical advice immediately. Aside from the chance that you could be infected with rabies, Siegel said, any animal bite poses a risk of infection.

As noted above, you can avoid rabies shots if the bat has been captured and tests negative for rabies. Unfortunately, Lane, the Massachusetts resident, didn’t learn that information until after her bat encounter. “The more I read, I thought, ‘Uh oh, I need to call my doctor,’ ” said Lane, who has since gotten all her rabies shots.