Ten minutes or so into “The Ex,” you’ll probably be moved to consider walking out—the opening scenes involving Tom and Sofia Reilly (Zach Braff and Amanda Peet), a New York couple (he’s a cook, she’s a lawyer) expecting their first child, are that terrible. Things improve a bit after they move to Ohio, where Tom will go to work with Sofia’s father (Charles Grodin) at a provincial ad agency while she becomes a full-time mommy to their son Oliver. But not by much. Though it boasts a few moments of odd, laid-back humor, what distinguishes the picture is that it’s not just bad, but perversely bad. It’s laudable that “The Ex” tries to be different. And sometimes weirdly quirky comedies work. (See, for example, such underrated Steve Martin pictures as “The Lonely Guy”—also with Grodin—and “The Man With Two Brains.”) But this one mostly goes awry.

The deal is that once Tom settles into his new job at the Sunburst Agency owned by a New Agey guru (Donal Logue), he finds himself undermined by his supposed mentor Chip (Jason Bateman), a guy in a wheelchair who’d had a crush on Sofia back in high school and is now out to ruin Tom to get her for himself. Of course, everybody but Tom thinks that Chip’s a great guy, and trying to expose his machinations only turns them against the struggling husband/daddy/son-in-law. Even Sofia finds Tom’s accusations absurd.

Comedy based on nasty one-upmanship can be very funny, but in this case the script alternates between flat bits of business and others (especially those centering on Chip’s disability) that aren’t just tasteless but repulsive. And while Bateman can do such Machiavellian stuff very well—he showed that at an early age as a conniving teen in the NBC sitcom “It’s Your Move” in the mid-eighties (an underrated series that deserves resuscitation on DVD)—his material here is so gruesomely poor (I was going to say lame or limp, but either would have been a horrible choice of words) that this talented comedian is actually annoying. And Braff makes such a soft, lifeless opponent that you don’t much care about whether or not he’ll eventually outmaneuver his rival. (He does, needless to say, but in a particularly obvious fashion.) And while Grodin extracts a few smiles via his patented schlub routine, Peet is drab, and Mia Farrow is utterly wasted as his wife, as is Logue.

In fact, if you’re waiting to hear where those rare good bits in “The Ex” are, the answer is that they’re provided by a couple of incidental players. One is young Lucien Maisel as neighbor kid Wesley, who shows not only a charmingly quizzical manner but a peculiar ability that makes him a potential spokesman for one of the firm’s customers. And another is Fred Armisen, who plays an oddball colleague of Tom’s who has a sideline as a marriage counselor. (Speaking of balls, one of the worst ideas in the script involves an imaginary one.)

But otherwise, watching “The Ex” involves more painful grimaces than smiles, especially since from a technical point of view it looks pretty barren and Jesse Peretz’s direction is flaccid. It’s almost as though the behind-the-camera crew were trying to emulate the work of the people who worked on “Office Space,” a picture that bombed at first but after a few years achieved cult status.

Maybe after a similar passage of time “The Ex” will in hindsight reveal some virtues, too. But at the moment, it exhibits very few.