问题
I wrote a short batch script (Windows 7) to bundle a Git repo and save a copy on a network drive:
@ECHO OFF
cd /D E:/mypath/myrepo.git
start "Window title" "C:\pathto\Git\git-cmd.exe" git bundle create X:/outpath/name.bundle --branches --tags
This works as expected, however, I would like the window to close when complete. I tried exit
but the window just returns to the directory specified by cd
, and remains open.
How can I close the window? (I've seen plenty of speculative answers in other posts, I'm asking how I can really/actually close the window in this case)
回答1:
try with :
start "Window title" "C:\pathto\Git\git-cmd.exe" git bundle create X:/outpath/name.bundle --branches --tags ^&exit
To exit the console of course you need exit
command. To execute two commands on one line you ussally use ampersand . But in this case you want the exit as part of START command ,but not be executed after start so you escape the &
with caret.
来源:https://stackoverflow.com/questions/41637282/close-cmd-window-after-git-command-in-batch-script