Dogs who bark at everyone do so because they are afraid, aggressive or excited. The answer to any of these problems is socialization. A dog who is used to being around people will learn to greet them quietly, but a dog who hasn't had much experience with strangers will react out of his basic nature, whether it is fear or excitement. Socialization from a young age is the key to a dog who is well-mannered and polite, but if you missed the opportunity when your dog was young, it isn't too late to teach him how to behave.
Manage the situation. If your dog looks out the front window to bark, rearrange the furniture so he cannot get to his favorite spot. If he barks when out walking, find a quieter route while you work on the problem.
Expose him on your terms. Expose him to what causes him to bark when you are ready to work with him. If he barks in the yard when you let him out in the mornings, you need to postpone your shower and go out with him until he changes his behavior.
Teach him an alternative activity. For example, if he barks while out on walks, make an abrupt U-turn and head off in the other direction when he starts barking. If he barks when someone knocks on the door, rather than answering immediately, call him to you and have him perform a "sit" or "down" before walking over to the door together.
Catch him being quiet. Be ready with treats close at hand so you can slip him one immediately when he does not bark at a typical trigger. When you're out walking and he sees others and doesn't bark, slip him a treat. When someone knocks on the door and he trots to you before you can call him, give him a treat. This reinforces the fact that his attention should be on you, and you expect him to be quiet.