问题
I am trying to close the db2cmd after executing a command. Goal is to get this file perfect before I schedule it with a task scheduler to run everyday at 2100 hours. The batch file starts execution of the command, the command gets executed but the prompt doesn't close.
I have been through the below links but no combination is working.
How to close the command line window after running a batch file?
How to automatically close cmd window after batch file execution?
Here is my short scriptstart C:\"Program Files"\IBM\SQLLIB\BIN\db2cmdadmin.exe "db2 -tvf D:\stats.sql > D:\stats.output"
The command works but the prompt remains open after completion. I have tried doing -
"&& exit 0",
"exit 0" in the next line,
"exit" in the next line,
"start db2cmdadmin "db2 -tvf D:\stats.sql > D:\stats.output""
But nothing closes the prompt. How can I correct this?
回答1:
You probably want to add the command line switch /c
to your command
start C:\"Program Files"\IBM\SQLLIB\BIN\db2cmdadmin.exe /c "db2 -tvf D:\stats.sql > D:\stats.output"
as explained in the manual.
回答2:
I haven't tried this, but it usually works for me. On at the end of `
start `C:\"Program Files"\IBM\SQLLIB\BIN\db2cmdadmin.exe "db2 -tvf D:\stats.sql > D:\stats.output"
Put
goto eof
Then put a loop
:eof
and exit So in total the code would be
@echo off
start `C:\"Program Files"\IBM\SQLLIB\BIN\db2cmdadmin.exe "db2 -tvf D:\stats.sql > D:\stats.output"
goto eof
:eof
exit
来源:https://stackoverflow.com/questions/33576184/close-db2cmd-prompt-after-command-execution-from-a-batch-file