Is there any way to automatically save command history to a file in cmd.exe, similar to bash's bash_history?

You could create a doskey macro to remap the EXIT command, as follows:

doskey exit=doskey/history$g$gc:\temp\commands.log$texit $1 $2

This would append the contents of your command history into a file named "c:\temp\commands.log" each time you exit the prompt by typing "exit".

CAUTION: I haven't tested potential side effects of using this with EXIT's "/B exitCode" parameters, but there shouldn't be any since you're capturing the parameters with "$1 $2" anyway.

This doesn't do exactly what you're looking for, but it does capture your command history as long as you exit using EXIT (vs. just closing the window).

More info and samples on DOSKEY macros are here: http://technet.microsoft.com/en-us/library/bb490894.aspx