The several courts having authority to grant relief by habeas corpus, may enter orders, when necessary, to bring before them any prisoner to testify, or to be surrendered in discharge of pretrial release , or for trial upon any criminal charge lawfully pending in the same court or to testify in a criminal proceeding in another state as provided for by Section 2 of the "Uniform Act to secure the attendance of witnesses from within or without a state in criminal proceedings", approved July 23, 1959, as heretofore or hereafter amended; and the order may be directed to any county in the State, and there be served and returned by any officer to whom it is directed.
735 ILCS 5/10-135