Nothing in this chapter shall prevent a court from issuing a writ of habeas corpus, when necessary, to bring before it a prisoner for trial in a criminal cause pending in the court, or to be surrendered in discharge of bail, or examined as a witness in any action or proceeding, civil or criminal, pending in such court, when the personal attendance and examination of the witness is necessary in the administration of justice.
12 V.S.A. § 3985