These devices you describe are also known as teen-repellents and take advantage of a well know fact that our hearing frequency range deteriorates with age, while it's not yet fully developed in pre-teen age. The most effective age range such devices could target is somewhere in the range of 12 to 24 years, and some such devices have various settings for crowd control of any age, too.
They cause high-pitched, high frequency noise in the range of roughly 17.5 kHz and up, limiting its influence to mostly teenagers. Several manufacturers exist already, and since it's not a technically challenging device to make, I suspect many may have made their own versions, too. The whole idea probably comes from research in perimeter alarms, where some use rapidly changing frequency high volume noise in a bid to disturb burglar's orientation (our inner ear).
You could test your hearing of these high frequency sounds online, for example with this YouTube clip, or a faster one here to see how much of an effect these devices would have on you. Make sure you select the highest quality setting (video quality and audio quality are coupled on YouTube), otherwise some extreme frequencies might get lost with compression.
So what is the point of these devices? Mainly, they serve as anti-loitering devices for public places where gathering of greater number of teenagers is not desirable, such as luxury departments in shopping malls, adult red district areas (not confirmed), and other places where masses of teenagers would potentially create a disturbance (rollerskating, loitering, whichever is considered as undesirable behaviour by us adults).
As you have probably already anticipated by now, they're highly controversial and have caused a public outcry in many countries that tend to respect human rights, defend and uphold civil liberties, or are otherwise concerned by too big of an influence of corporations on general population.
One such device is Mosquito Anti Loitering made by MST. The page there describes more about what it's supposed to do and where to use it (that's a job for advertisers really, so best left to them). Needless to say, they left out all the bad about it, and don't address questions such as how does it affect animals and if, in what way, is it effective (street punks might be less sensitive to these sounds simply because they probably wouldn't care so much to lose their hearing abilities and rather stand next to the loudspeakers in loud concerts - to hear it better of course, while the ones it would work better on would probably be the quiet, library goer types), if it can cause nausea or similar discomfort even to generations that wouldn't be able to hear these noises (just because it's beyond our hearing range, doesn't mean it doesn't have a real physical effect on us), or indeed, if it can be considered safe to pregnant women and their unborns.
A proper article about these devices can also be found here. So far, it seems, more money went into advertising these devices than actually determining their effect on our health (or health and change in behavioral patterns of other species, like e.g. dogs, cats, horses and birds). This is certainly one of those things we'll still need to properly address in the near future, while in the meantime their producers and advertisers will gladly exploit the fact that we didn't.
Teenagers strike back
UPDATE: I was reminded of an interesting bit of information relevant to this thread by @ThomasPornin in the comments below. Thanks Thomas! What follows is a partial transcript (full transcript available in link) from episode 6 of Dara Ó Briain's Science Club, where it was also mentioned:
This phenomenon became very well-known, by the way, because some
company marketed an alarm that shopkeepers could play outside their
shops to clear teenagers from in front of the shop, because only
teenagers could hear it. My favourite thing about it is that the
teenagers recorded the tone and used it as a ringtone on their phone,
because teachers can't hear it in school. So, they can actually phone
each other in class, which I think is genius.
 Dara Ó Briain, Dara Ó Briain's Science Club, Episode 6, 0:28:59.00 - 0:29:26.64
So there we have it, a comical cause and effect, as @SteveS also pointed out in the comments (one of the first members of IT Security by the way). I didn't link to any available online video clips, as they're of course all copyrighted and/or might not be available in all countries (e.g. BBC iPlayer). Do try to find them though, they're most interesting to watch and come with a fair bit of science & technology related situational comedy on top of factual information and personal opinions of some of the best scientists of today.