Rodent spray is meant to do exactly that. There have been mixed reviews over the effectiveness of using repellent sprays, but since they're cheap and readily available, there's no harm in trying them out if you like.
The popularity of these sprays is partially due to the interest in humane pest control. Some sprays are made of natural substances and have no unpleasant odor to humans. The spray acts as a deterrent to rats, mice, squirrel, and other rodents or wildlife who want to chew on something like your walls, fences, posts, etc. It leaves a bitter taste that quickly discourages chewing.
Rodent spray can be applied, for example, after the entry points into a house have been sealed off - apply the spray around the repaired hole to discourage animals from chewing around it to create a new entry point.
Be sure to follow all directions on the bottle, including any safety instructions. Check the label to see if the spray is safe for both kids and for pets.
The effects of the spray (if it indeed does work for you) doesn't last forever and may need to be applied at regular intervals. Rodent spray will likely not be the only thing needed to keep rodents away - see the article on preventive pest control for things that can be done in and around the home to keep pests away on a long-term basis.