2017-06-13 7 views
1

は、私が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 

しかし、Sysinternalsのではと予想、procexpユーティリティなどコメントが指摘したように、のWin32 WMIオブジェクトのインタフェースを使用すると、それを得ることができ、また

enter image description here

:スイートは、完全なコマンドラインを取得することができます。しかし、なぜこの機能がpowershellにないのですか?

+0

[PowerShellまたはC#でプロセスのコマンドライン情報を取得する方法](https://stackoverflow.com/questions/17563411/how-to-get-command-line-info-for-a-) powershell-or-c-sharpで処理する) – LotPings

+0

引数やstartinfoが空である理由を知っていますか? – fluter

+0

申し訳ありません。 MicroSoftがSysinternalsを罵倒した理由があったに違いありません。タスクマネージャは成長しましたが、私はまだProcExpを使用しています。 – LotPings

答えて

1

ない答えを理解してください、しかし@LotPingポイント:

$proc = Get-Process notepad 
$pInfos = Get-WmiObject Win32_Process -Filter "name = '$($proc.MainModule.ModuleName)'" 
$pInfos.CommandLine 

CommandLineは、このオブジェクトがに使用されているときは、startinfoで何かを見つけるあなたProcessXP


と同じ情報を提供しますプロセスを開始します。

$startInfo = New-Object Diagnostics.ProcessStartInfo 
$startInfo.Filename = "notepad" 
$startInfo.Arguments = "toto.txt" 
$startInfo.UseShellExecute = $false 
$Proc = [Diagnostics.Process]::Start($startInfo) 

It exこれはWin32 CreateProcessをカプセル化するオブジェクトProcessを使用してプロセスを開始する多くの方法です。コマンドラインが使用されるときは、startinfoにデータが見つかりません。プロセスがプログラムによって開始されたときに追加できます。

+0

私の質問はなぜこのような情報が 'ProcessStartupInfo'にありませんか? WMIを使用するのは最後の手段です。 – fluter

+0

私の答えで説明してください。 – JPBlanc

関連する問題