How to prevent batch window from closing when error occurs?

前端 未结 4 2031
予麋鹿
予麋鹿 2021-02-02 05:53

I\'m trying to write batch script to create a folder if it does not already exist. Following up the online examples, below is my script.

The problem is;

4条回答
  •  臣服心动
    2021-02-02 06:48

    You could put this line at the beginning of the batch file:

    if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit )
    

    What this line does is, the first time you run it, it re-launches itself in a subprocess that doesn't exit after it finishes running the batch file.

提交回复
热议问题