I don't think we will stop Iran or DPRK from getting nukes. They will figure it out eventually. The best we can hope for is to push back the timeline. Once Iran goes nuclear it will probably be a prolonged Mexican standoff until they get a leader moderate enough to normalize relations with us (like thats gonna happen) or their shit falls apart in another revolution.
If we do have a ground war with Iran, I think it is more "winnable" than Afghanistan, because Iran is more formalized and less clannish than AFGN. It won't be as much a guerrilla war, but it will still be slow going as Iran has a mountain range on every border.