Saving windows command prompt history to a file

miyahira used Ask the Experts™
Is possible to save windows command prompt history to a file?
I'm going to work in sqlplus and would like to save in a log file all commands that were used and executed.
Example, would like to save all commads executed in a session:

C:\> sqlplus /nolog
sql> connect / as sysdba
sql> select * from v$version;
etc, etc

I tried to do before:
doskey /history >> C:\commands.log

But it does not record anything. I'm in a Windows Server 2008 64 bits.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Use the SQLPlus command spool:

spool C:\commands.log
[some commands]
spool off

Open in new window

Note that this will output the results of the queries you run as well. I can't recall if there's a way to prevent that, but I think there is.

You could also run it as a batch file like:
start "" thebatchfile.bat >>"Log File.log"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial