开发者

How to close a console window that has been created by "START"?

开发者 https://www.devze.com 2023-04-04 01:51 出处:网络
I use Windows XP and have the following two batch files: start_up.bat: C: cd \"C:\\programs\\hsqldb\\hsqldb-2.1.0\\hsqldb\\bin\\\"

I use Windows XP and have the following two batch files:

start_up.bat:

C:
cd "C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\bin\"
start C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\bin\runServer.bat
C:\programs\tomcat\apache-tomcat-6.0.26\bin\startup.bat

shut_down.bat:

cmd /c "C:\programs\tomcat\apache-tomcat-6.0.26\bin\shutdown.bat | ant -verbose -buildfile shutdown.xml hsqldb-stop" 

The directory from which I invoke these two files contains:

start_up.bat
shut_down.bat
shutdown.xml

As you can see, I am trying to start up HSQLDB + TOMCAT and then shut them down.

The problem is, the window where HSQLDB runs will not close automatically after HSQLDB shuts down (the ant command shuts down HSQLDB). I think it is because I created this window by "START", but I do not know how close that window.

If I try to create that window and give it a name, e.g. the name "db", by:

start "db" C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\bin\runServer.bat

then I still don't know how to close a window according to its name.

UPDATE:

I've found a way to "close" a window by i开发者_StackOverflowts title:

taskkill /f /fi "WINDOWTITLE eq mytitle"

So I have changed my batch files to be:

start_up.bat:

C:
cd "C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\bin\"
start "hsqldb" C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\bin\runServer.bat
C:\programs\tomcat\apache-tomcat-6.0.26\bin\startup.bat

shut_down.bat:

cmd /c "C:\programs\tomcat\apache-tomcat-6.0.26\bin\shutdown.bat | ant -verbose -buildfile shutdown.xml hsqldb-stop"
taskkill /f /fi "WINDOWTITLE eq hsqldb"

And now the "hsqldb" window closes after HSQLDB is shut down.

If you find a more direct solution feel free to let me know.


You may want to try calling shutdownbat (inside shut_down.bat) with a "call" command instead of "cmd".

0

精彩评论

暂无评论...
验证码 换一张
取 消