Whenever it appears by the complaint, or by affidavit, that any one is illegally held in custody or restraint, and that there is good reason to believe that such person will be taken out of the jurisdiction of the court in which the application for a habeas corpus is made, or will suffer some irreparable injury before compliance with the order can be enforced, the court may enter an order directed to the sheriff or other proper officer, commanding him or her to take the prisoner thus held in custody or restraint, and forthwith bring him or her before the court to be dealt with according to law. The court may also, if it is deemed necessary, order the apprehension of the person charged with causing the illegal restraint. The officer shall execute the order by bringing the person therein named before the court, and the like return and proceedings shall be had as in other orders of habeas corpus.
735 ILCS 5/10-118