When I tried to get command line arguments of a executable, I tried inspect the ProcessStartInfo
structure returned by Get-Process
, but the argument field is empty no matter what:
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
But as expected, the procexp
utility in sysinternals suite can get full command line:
Also, as comments pointed out, using win32 wmi object interface can get it. However, why is this feature missing from powershell?