How to stop currently running process in cmd without stopping the batch execution?

时间:2017-12-18 08:01:47

标签: windows batch-file cmd

I have a looped batch file that runs another process.

If a process throws an error, it will basically restart itself.

Here is the short version:

<!-- main.xhtml -->

<ui:include src="node.xhtml">
    <ui:param name="directory" value="#{myBean.myListing}"></ui:param>
</ui:include>


 "myListing" consists of ArrayList of folders and files



<!-- node.xhtml -->

<ui:composition>
    <ui:repeat value="#{folder}" var="myItem">

            <h:commandLink action="#{myBean.showMyChildren}">
                <h:graphicImage value="images/plus.png" rendered="#{!item.file and (myItem.children.size() > 0)}"/>
            </h:commandLink>
            <h:graphicImage value="images/directoryImage.png" rendered="#{!myItem.file}"/>
            <h:graphicImage value="images/mybutton.png" rendered="#{myItem.file}"/>
            <h:outputText value="#{myItem.fileName}" > <br />

            <h:panelGroup rendered="#{myBean.revealChildren}" >
                <c:if test="#{myItem.children.size()>0}">
                    <ui:include src="node.xhtml" >
                    <ui:param name="dir" value="#{myItem.children}"></ui:param>
                </ui:include>  
            </c:if>
        </h:panelGroup> 
    </ui:repeat>    
</ui:composition>

The problem with the above code is that sometimes I need to forcefully restart the currently running process.

Now if I press ctrl+c it actually terminates the batch itself and closes the window, which is not what I want........

I could have written another batch file with taskkill command, but I can't because there are many instances of this process with different process ids.

Appreciate your help!

1 个答案:

答案 0 :(得分:0)

Actually I can use start /wait command, it's the same as the above as it will wait for the file to execute but will open it in a different window, which I could easily close and force the program to restart without terminating my batch.

loop

Note: upon closing the batch may prompt to terminate execution. I found the way dealing with it here: https://superuser.com/questions/35698/how-to-supress-terminate-batch-job-y-n-confirmation

:start
start /wait C:\Squid\bin\squid.exe
timeout 1
goto start