Sometimes the answer is: You can't.
For example, I once worked with someone who regularly got frustrated and resentful about several demands of the job and did everything he could to resist them. He would ignore explicit instructions because he disagreed with them, neglect projects he didn't like working on, and constantly argue about the things he didn't like. He was trying to force the job to become something it wasn't. Rather than seeing the job for what it was, and deciding if it was something he was willing to live with or not, he kept himself (and others around him) miserable by engaging in a constant struggle against the realities of the job.
Ultimately, it didn't really matter that he wanted the job to be something different. It wasn't, and I didn't want it to become what he wanted to make it. Eventually I asked him to decide whether he wanted the job as it was--knowing that the things he complained about weren't going to change--and I pointed out that there was no shame in deciding that it just wasn't for him. It completely changed the dynamic for both of us. It stopped being adversarial, and was transformed into two people figuring out the best way to deal with the reality of a situation.
The key here is being honest with yourself and with your manager. Talk about the things that are making you unhappy and find out if there's any chance of changing them. Sometimes there is. Other times, there isn't. Once you know that, you can make good decisions for yourself with complete information.
[See Alison Green's advice on the right time to resign]
This doesn't always mean that you should choose to leave if you don't get the changes you'd like. Often you will end up deciding that you can live with the situation, reasonably happily. Sometimes simply knowing what will and won't change makes things easier to deal with, and you can surprise yourself by ending up pretty content with things that drove you crazy when you were focused on battling them.
The idea is that you want to commit to seeing and dealing with reality, and to making decisions based on what really is, not on what you want it to be. That's a lot more satisfying than a constant struggle.
Alison Green is the author of Managing to Change the World: The Nonprofit Leader's Guide to Getting Results. She is chief of staff for the Marijuana Policy Project, a nonprofit lobbying organization, where she oversees day-to-day management of the staff as well as hiring, firing, and staff development. Her writings have been published in the Washington Post, the New York Times, Maxim, and dozens of other newspapers. She blogs at Ask a Manager.