A safer method than a barking problem in a dog is training. Most dogs bark because they are anxious, especially small dogs. Shocking them when they bark is not going to resolve the anxiety. In fact, it will make it worse. Thus, you may eventually stop the barking, but you have not helped the underlying problem. Those anxious feelings will show themselves in other ways such as chewing, inappropriate elimination or even aggression.
If your dog is barking at a window or in the yard etc, do not give them access to that area when you are gone. Give them a quiet room with a comfortable bed, treats and bones. Don't let your dog practice the behavior all day. When you are home, teach a no bark command. Play with him in a way that will make him bark. Then say "quiet" when he stops. Reward with good treats. Practice this until he responds every time.