“Hedwig,” which saw Harris shed the persona of “How I Met Your Mother” ladies-man Barney Stinson to portray the musical’s titular East German transgender rocker, had looked on track to turn a profit since early in its run. The title, which began previews March 29, debuted with relatively robust weekly sales that snowballed into hit-show numbers as the production collected glowing reviews followed by four Tonys, including the trophy for musical revival.

Over the last six weeks, the production has pulled in more than $1 million per week, a feat made more remarkable by the show’s comparatively small theater (the 1,000-seat Belasco) and by the fact that the tuner only plays seven performances per week as opposed to eight, which is the standard on Broadway.

The recoupment caps off a good summer for lead producer David Binder, whose revival of “Of Mice and Men,” starring James Franco and Chris O’Dowd, recently made it into the black. That production earned more mixed reviews than “Hedwig,” but the star power of the cast combined with the well-known title have helped keep audience interest high.

John Cameron Mitchell and Stephen Trask’s 1998 musical “Hedwig and the Angry,” which premiered Off Broadway and was later adapted into a 2001 film, has amassed a notably fervent fanbase in the years since its debut. But much of the current production’s success seems attributable to the star power of Harris, the Hollywood veteran whose post-“Doogie Howser M.D.” resurgence has encompassed well-received emcee gigs on high-profile awards shows (including the Emmys and the Tonys) as well as nine seasons on hit CBS series “How I Met Your Mother.”

Whether business at “Hedwig” will hold up after Harris departs the production Aug. 17 remains an open question. Andrew Rannells, the former star of Broadway’s “The Book of Mormon” who went on to TV roles in “The New Normal” and “Girls,” does not have the same sizable fanbase Harris does.

The capitalization of a Broadway production encompasses start-up costs including rehearsals, advertising and set construction. Now that those expenses have been recouped at “Hedwig,” the production’s revenue is pure profit, minus weekly running costs such as actor and musician salaries.

Rannells steps into the Broadway production of “Hedwig,” directed by Michael Mayer (“Spring Awakening”), Aug. 20.