
687 S.W.2d 397 (1985)
Leticia Pollock BENAVIDES, Relator,
v.
Honorable Ruben GARCIA, Judge of the 49th Judicial District Court of Webb and Zapata Counties, State of Texas, Respondent.
No. 04-85-00018-CV.
Court of Appeals of Texas, San Antonio.
January 30, 1985.
*398 Donato Ramos, Person, Whitworth, Borchers & Morales, Julio A. Garcia, Laredo, for appellant.
Emilio "Chito" Davila, Laredo, for appellee.
Before BUTTS, REEVES and TIJERINA, JJ.

OPINION
REEVES, Justice.
This is an original mandamus action in which relator, Leticia Pollock Benavides, seeks an order directing Judge Ruben Garcia of the 49th District Court of Webb and Zapata Counties to dismiss a divorce suit presently pending in that court.
Relator filed suit for divorce on September 28, 1983. Respondent in the divorce action (defendant) filed an answer containing a general denial and a request that he be appointed managing conservator of the parties' son. Relator filed a motion to dismiss on April 11, 1984, and subsequently filed a motion to transfer the case, a motion for continuance, a jury demand, another motion for continuance, an amended original petition, and finally, a second motion to dismiss. Prior to her second motion to dismiss, the trial court entered an order appointing a guardian ad litem for the parties' three minor children. According to the trial court's docket sheet, the court, on its own motion, then set the case for hearing on the merits on January 11, 1985. We granted relator's motion for leave to file petition for writ of mandamus pursuant to our authority under TEX.REV.CIV.STAT. ANN. art. 1824 (Vernon Supp.1985) and issued a temporary restraining order requiring that respondent take no further judicial action in the cause pending our inquiry.
A writ of mandamus will issue to control the conduct of a public official when the duty to do the act commanded is clear and definite and involves no discretion, i.e., a ministerial act. Turner v. Pruitt, 161 Tex. 532, 342 S.W.2d 422, 423 (1961); Womack v. Berry, 156 Tex. 44, 291 S.W.2d 677, 682 (1956); Smith v. Rankin, 661 S.W.2d 152, 153 (Tex.App.Houston [1st Dist.] 1983, no writ).
On a timely motion, the plaintiff has an absolute unqualified right to take a non-suit before presentment of all plaintiff's evidence as long as the defendant has not already made a claim for affirmative relief. The granting of the non-suit is a purely ministerial act. Johnson v. Harless, 651 S.W.2d 259, 260 (Tex.1983); Greenberg v. Brookshire, 640 S.W.2d 870, 871, 872 (Tex.1982); TEX.R.CIV.P. 164. No specific procedures are required under TEX.R. CIV.P. 164. The mere filing of the motion with the clerk or an oral announcement in open court are sufficient. Greenberg v. Brookshire, supra at 872.
The defendant may defeat a plaintiff's right to discontinue the entire proceeding when the defendant seeks affirmative relief. However, he must do more than pray for affirmative relief. He must allege facts which show he has a cause of action, independent of the plaintiff's claim, on which he might recover even if the plaintiff abandons or fails to establish his cause of action. Greenberg v. Brookshire, supra; Lipsey v. Lipsey, 660 S.W.2d 149, 151 (Tex.App.Waco 1983, no writ); Newman Oil Company v. Alkek, 614 S.W.2d 653, 655 (Tex.Civ.App.Corpus Christi *399 1981, writ ref'd n.r.e.), on remand, 657 S.W.2d 915 (Tex.App.Corpus Christi 1983, no writ). The defendant filed a pleading entitled "Respondent and Cross-Petitioner's Original Answer" in which he asserts a general denial and requests that he be named managing conservator of the parties' son. This pleading fails to suffice as a counterclaim for affirmative relief. The defendant does not allege facts which show he has a cause of action independent of relator's claim. If the defendant does no more than resist the plaintiff's recovery, the plaintiff has the absolute right to a non-suit. Newman Oil Company v. Alkek, supra.
Mandamus will lie to direct a lower court to perform a purely ministerial function. Since the defendant alleged no facts to support a cause of action, the trial court had no choice but to grant relator's motion to dismiss as to the divorce action.
However, relator's non-suit does not divest the trial court's jurisdiction to enter temporary custody orders to serve the best interests and protect the welfare of the minor children of the parties. Ex parte Brown, 382 S.W.2d 97, 99 (Tex.1964); Strange v. Strange, 464 S.W.2d 216, 219 (Tex.Civ.App.Fort Worth 1970, writ dism'd); McClendon v. McClendon, 289 S.W.2d 640, 643 (Tex.Civ.App.Fort Worth 1956, no writ); TEX.CONST. art. V, § 8. The temporary orders entered upon the dismissal of the underlying divorce suit continue in full force and effect until set aside by the issuing court or modified by another court of competent jurisdiction. Ex parte Brown, supra.
Respondent argues that we have no authority to issue a writ of mandamus because neither the minor children nor their court appointed guardian ad litem were notified of the petition for writ of mandamus. All persons or parties whose rights would be injuriously affected by the issuance of the writ are necessary parties. Lanford v. Smith, 128 Tex. 373, 99 S.W.2d 593, 594 (1936). However, these adverse parties need not be made parties in a mandamus proceeding which involves only the ministerial and nondiscretionary duties of the trial court. The writ then runs only against the trial judge. State Bar of Texas v. Heard, 603 S.W.2d 829, 832-33 (Tex. 1980); Dick v. Kazen, 156 Tex. 122, 292 S.W.2d 913, 916-17 (1956). Further, the minor children involved in the case remain under the jurisdiction of the trial court until the temporary orders are set aside by that court or modified by another court of competent jurisdiction. Their rights are not injuriously affected.
We conditionally grant the writ of mandamus in part. If Judge Garcia fails to enter an order of dismissal without prejudice of relator's divorce action, the writ will issue as to the divorce action.
