Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have windows log every command I type & the output I see on the console? Sometimes I find that I want to see what I did 2 hours ago just to be sure I typed a certain parameter in correctly.

share|improve this question
Is it just me or is this comment almost always at the top of SU? – Frank Feb 6 '14 at 4:18
It does seem to be pretty popular, although I can't imagine it's that popular. – Lanissum Apr 12 at 5:24
up vote 5 down vote accepted

Yes. You can use Start-Transcript and Stop-Transcript.

You have given me the idea to put that in my PowerShell profile so that it starts automatically. This is what I have come up with:

$transcriptDir = Join-Path ([Environment]::GetFolderPath("MyDocuments")) PowerShellTranscripts
if (-not (Test-Path $transcriptDir))
    New-Item -Type Directory $transcriptDir
$dateStamp = Get-Date -Format ((Get-culture).DateTimeFormat.SortableDateTimePattern -replace ':','.')
    Start-Transcript "$transcriptDir\Transcript.$dateStamp.txt"
catch [System.Management.Automation.PSNotSupportedException]
    # ISE doesn't allow transcripts.
    Write-Host "No transcript. Not supported in this host."
share|improve this answer
Thank you dangph, this would be sufficient for my purposes and it is simple to accomplish. – Lanissum Feb 10 '14 at 22:59

Note: I prepared this answer, and then realized you are probably asking specifically about commands executed within PowerShell. Rather than erase my effort, I am going to post in case it help someone looking at doing the same thing within DOS. Doing a bit of reading, it looks like @dangph has probably given the correct answer for PowerShell.

To log commands to a file:

doskey /history >> commands.log to append your command history to a log.

This page explains in details, but in a nutshell you can pipe your commands to a file of choice before closing your DOS emulator. You wouldn't have to do this until after you're done (not sure if buffer comes into play with large volume of commands)

To log command output to a file:

You would probably want something like...

dir >> a.txt | type a.txt. As mentioned in that answer, you are writing command output to a file and then printing the contents of the file, but I think it fits the bill and would be automatic if you used it with every command. If you tweak a little, I think you could probably modify to also write the command as well as the output.

Perhaps someone can improve or suggest a more user-friendly solution to do both (append command and results) at once, as statements are executed.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .