The ant queen must be killed in order to get rid of ants permanently. Since the queen is nearly always deep in the nest, unless you are treating the nest directly, the best solution is to use ant bait. Spraying haphazardly will almost never get rid of ants in fact, it can actually multiply the problem because some ant species will "bud" when stressed, which means that they will divide their colony.
Clean the area where ant are active to minimize them but more importantly, to make the bait their only food choice
Choose a gel or liquid ant bait for best results because the taste and texture of them is designed to be like ant's natural food. Hard baits like that in stick on bait stations is often ignored by ants. Baits sold in toothpaste like tubes such as those sold by Maxforce and Combat work best and they are easy to use.
Apply small amounts of the bait in many areas as opposed to one or two large clumps. Place it where the ants have been seen eating, in their trails if trailing, where they have been seen walking and where they have been observed entering the area.