Close db2cmd prompt after command execution from a batch file

混江龙づ霸主 提交于 2020-01-11 14:12:30

问题


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 script
start 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!