4

is there any place in windows where in admin or super user changes/commands are stored? like how linux has .bash_history for root?

2
  • If you give a little bit more context on what exactly you are trying to achieve, we might be able to point you to the proper source of information. Jun 29, 2010 at 7:36
  • Related: superuser.com/questions/290107/…
    – idbrii
    Jun 20, 2011 at 15:50

4 Answers 4

2

for 'powershell' i found this blog entry:

$MaximumHistoryCount = 1KB

if (!(Test-Path ~\PowerShell -PathType Container))
{   New-Item ~\PowerShell -ItemType Directory
}

function bye 
{   Get-History -Count 1KB |Export-CSV ~\PowerShell\history.csv
    exit
}

if (Test-path ~\PowerShell\History.csv)
{   Import-CSV ~\PowerShell\History.csv |Add-History
}

then you have to end the session with "bye" (instead of "exit" or closing the window via the "x" button).

1
  • no need to do that. PowerShell already saves the history by default
    – phuclv
    Jun 21, 2022 at 0:32
1

the only thing which comes "close" to something like a "stored history" (but only for the current session) is to press F7.

1
1

No, the windows Command Prompt does not have automatic logging facilities.

And actually, the linux .bash_history is not only for root - it's for any bash user that doesn't explicitely disable it.

1

Besides F7, to print the command history of current session, run:

DOSKEY /history
1
  • In case anyone wants to do this in C, it's using the following undocumented calls: DWORD GetConsoleCommandHistoryLengthW(LPWSTR ExeName) and DWORD GetConsoleCommandHistoryW(LPWSTR Buffer, DWORD BufferLength, LPWSTR ExeName).
    – Eryk Sun
    Dec 23, 2014 at 8:02

You must log in to answer this question.