Ron van der Heijden
Ron van der Heijden

Reputation: 15080

Prevent batch file in CMD from closing without using Pause

Currently I want to run a batch file that fires the command git log and show me that log. After that I need to be able to commit and view the status so this prompt may not disappear after a key press.

I've searched the net and the only answer people have is pause which close the prompt after a keypress.

Does anyone have the solution for me? Currently I made a shortcut to cmd.exe and made the target my folder, but I want to execute some commands also.

Thanks in advance.

Upvotes: 0

Views: 525

Answers (1)

John Langstaff
John Langstaff

Reputation: 868

This (below) tested OK in Windows 7. To exit the window it creates, type "exit" when done.

start cmd /K "cd \[the-target-folder] && git log"

Where: [the-target-folder] you replace with your target folder

Note: && lets you run two commands on one line /K is a parameter to the cmd shell program which which carries out the command specified by string and remains.

Upvotes: 1

Related Questions