Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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? –  Chipperyman Feb 6 at 4:18
add comment

2 Answers

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 ':','.')
try 
{
    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 at 22:59
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.