当我试图得到一个可执行的命令行参数,我想检查由Get-Process
返回ProcessStartInfo
结构,但参数字段为空不管是什么:为什么ProcessStartInfo的参数是空的?
PS C:\> ps notepad
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
272 15 3484 19888 0.39 33696 1 notepad
PS C:\> $(ps notepad).StartInfo
Verb :
Arguments :
CreateNoWindow : False
EnvironmentVariables : {ConEmuBaseDir, ConEmuConfig, ConEmuArgs, PROCESSOR_REVISION...}
Environment : {[ConEmuBaseDir, C:\Users\fluter\Tools\ConEmu.Core.17.1.18.0\Tools\ConEmu], [ConEmuConfig, ], [ConEmuArgs, ], [PROCESSOR_REVISION, 4501]...}
RedirectStandardInput : False
RedirectStandardOutput : False
RedirectStandardError : False
StandardErrorEncoding :
StandardOutputEncoding :
UseShellExecute : True
Verbs : {}
UserName :
Password :
PasswordInClearText :
Domain :
LoadUserProfile : False
FileName :
WorkingDirectory :
ErrorDialog : False
ErrorDialogParentHandle : 0
WindowStyle : Normal
但正如所料,procexp
实用的Sysinternals套件可以得到完整的命令行:
此外,作为评论中指出,使用Win32 WMI对象接口可以得到它。但是,为什么PowerShell缺少这个功能?
可能的[如何获取PowerShell或C#中的进程的命令行信息]的副本(https://stackoverflow.com/questions/17563411/how-to-get-command-line-info-for-a- process-in-powershell-or-c-sharp) – LotPings
你知道为什么参数或startinfo是空的吗? – fluter
对不起,没有。必须有一个原因,为什么MicroSoft推出Sysinternals。任务管理器增长更好,但我仍然使用ProcExp。 – LotPings