Question

My batch script contains this code:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i -c "git fetch -q --all -p"

When I run it by double clicking, or when started by the task scheduler it wont close the window after it's done. I've tried Start "" "C:..., Exit 0, cmd \c,GOTO :EOF and nothing seems to work.

Was it helpful?

Solution 2

For some reason calling using C:\Program Files (x86)\Git\bin\sh.exe leads to two ssh-agent.exe processes that won't stop even after calling exit. So my solution was to instead use the git command which calls C:\Program Files (x86)\Git\cmd\git.exe and does not leave ssh-agent.exe processes running and allows the command window to close.

OTHER TIPS

I believe it's because you're opening a window which is calling sh.exe, opening it in another window. There is nothing to tell that window the close after the first one does.

Try adding & exit to the end of your git command.

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i -c "git fetch -q --all -p & exit"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top