@echo off
echo Starting evernote...
start "" "C:\Program Files (x86)\Evernote\Evernote\Evernote.exe
echo Starting vscode...
start "" "C:\Program Files (x86)\Microsoft VS Code\Code.exe"
echo Starting Chrome...
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
另一種寫法是(這種不推薦溃论,可以用來理解):
@echo off
echo Starting evernote...
cd C:\Program Files (x86)\Evernote\Evernote
strat Evernote.exe
cd C:\Program Files (x86)\Microsoft VS Code
strat Code.exe
echo Starting Chrome...
cd C:\Program Files (x86)\Google\Chrome\Application
start chrome.exe
存在的問題是悠栓,不能自動退出...
方案1:刪繁就簡 自動退出失敗
start "" "C:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
start "" "C:\Program Files (x86)\Microsoft VS Code\Code.exe"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
方案2:taskkill殺死進程 自動退出失敗 打不開vscode
start "" "C:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
start "" "C:\Program Files (x86)\Microsoft VS Code\Code.exe"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
taskkill /im cmd.exe
方案3:到segmentfault提問...
方案4:調整了下開啟順序 自動退出成功
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
start " " "C:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
start " " "C:\Program Files (x86)\Microsoft VS Code\Code.exe"
方案5:繼續(xù)試驗 自動退出成功
@echo off
echo Starting evernote...
start "" "C:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
echo Starting Chrome...
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
echo Starting vscode...
start "" "C:\Program Files (x86)\Microsoft VS Code\Code.exe"
由此可見,bat文件中應用程序的開啟順序可能也會導致exit命令的失效惫周。
PS:
添加了pause命令后尘惧,會出現(xiàn)“按任意鍵以繼續(xù)...”,但是會按任意鍵繼續(xù)失敗递递,更為嚴重的是喷橙,關閉cmd窗口后vscode也會同時關閉。這很有趣登舞。
期待和大家交流贰逾,共同進步,歡迎大家加入我創(chuàng)建的與前端開發(fā)密切相關的技術討論小組:
- SegmentFault技術圈:ES新規(guī)范語法糖
- SegmentFault專欄:趁你還年輕菠秒,做個優(yōu)秀的前端工程師
- 知乎專欄:趁你還年輕疙剑,做個優(yōu)秀的前端工程師
- Github博客: 趁你還年輕233的個人博客
- 前端開發(fā)QQ群:660634678
微信公眾號: 人獸鬼 / excellent_developers
努力成為優(yōu)秀前端工程師!