简体   繁体   English

记录cmd.exe的命令行

[英]record command lines of cmd.exe

I need to record some command lines inputs wich are typed on cmd.exe program on Windows . 我需要在Windows上记录一些在cmd.exe程序上输入的命令行输入。 I launch it from a powershell process, so I try this method explained here : 我启动它从一个PowerShell进程,所以我试试这个方法介绍在这里

PS (location)> cmd.exe | Tee-Object -file Cmd.exe.log

It's getting closer but I need to get this... 它越来越近但我需要得到这个......

  • How to record ONLY the typed command, not the output ? 如何只记录键入的命令,而不是输出?

  • How to see the prompt cursor, how to keep the "arrow" special command thrown with the keyboard recalling the previous commands ? 如何查看提示光标,如何保持“箭头”特殊命令抛出键盘调用以前的命令?

There is Start-Trascript which logs all the commands you entered. Start-Trascript记录您输入的所有命令。 More in official documentation: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-6 更多官方文档: https//docs.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view = powershell-6

The full output of the example trace is 示例跟踪的完整输出是

**********************
Windows PowerShell transcript start
Start time: 20190322104506
Username: DOMAIN\user
RunAs User: DOMAIN\user
Configuration Name: 
Machine: MAICHINE_NAME (Microsoft Windows NT 10.0.17763.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 31428
PSVersion: 5.1.17763.316
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.316
BuildVersion: 10.0.17763.316
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\transcripts\transcript0.txt

C:\projects\> ls


    Directory: C:\projects\


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       03/01/2019     16:07                X
d-----       18/02/2019     16:56                Y
d-----       21/03/2019     15:49                Z
d-----       22/03/2018     16:17                T


C:\projects\> cat .\paket.lock
STORAGE: NONE

C:\projects\> Stop-Transcript
**********************
Windows PowerShell transcript end
End time: 20190322104539
**********************

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM