PowerShellで、標準入力をMessageBoxに出すMessageBox.PS1を作る。(その3)
(その1)と(その2)は、相互補完関係にあるため、両方の技を合わせます。
これで、標準入力がコンソール、パイプ、リダイレクションのすべての場合に対応します。
MessageBox.PS1
$stdin=@()
$input|foreach{$stdin+=$_}
if($stdin.length){
$stdin=[String]::Join("`r`n",$stdin)
}else{
$stdin=[System.Console]::In.ReadToEnd()
}
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show($stdin)
« PowerShellで、標準入力をMessageBoxに出すMessageBox.PS1を作る。(その2) | トップページ | PowerShellの.PS1ファイルを起動するバッチファイル(その3) »