I have a script that is supposed to sit there, happily running in a command window, spewing out data... but I want the window to close automatically when the script finishes or crashes. The script is auto-restarted by other processes and I don't want my processing machines to become polluted with unused terminals.
In a pinch, I have considered settin开发者_JS百科g up the scripts as windows services that dump their output to a file and just having the command windows "tail -f" the output files, but I"d prefer not to make major changes to a system that already works well.
When you start a command line program that's the usual behavior. The console will stay there as long as the process is running and once it dies (naturally or by accident) the console window closes.
This also holds true for scripts, batch files and the like.
If you explicitly run cmd
with a batch file or program, then you should provide the /c
argument instead of /k
.
精彩评论