CHICAGO — Gov. Scott Walker of Wisconsin, who gave up his quest for the 2016 Republican presidential nomination last month, signed into law on Friday a measure that limits a longstanding tool against political corruption that has been used in investigations of Mr. Walker and his allies.

The John Doe law, as it is called in Wisconsin, has given prosecutors the power to obtain search warrants and order people to testify and turn over documents in investigations that typically take place in secret.

Under the measure, which easily passed both Republican-controlled chambers of the State Legislature, prosecutors will no longer be allowed to use the John Doe law to investigate crimes that include bribery and misconduct in office. The legislation will also limit proceedings to six months and lift an order that barred subjects of an investigation from discussing it publicly.

Prosecutors can still use the John Doe law to investigate violent crimes and drug-related felonies.

Six of Mr. Walker’s aides or allies were convicted as a result of a John Doe investigation. Mr. Walker’s former government office and, later, his campaign were the focus of John Doe investigations of campaign activities and fund-raising, but he was never charged.