1
メッセージボックスを生成するためにpowershell.exeに引数を与える方法を教えてください。ここで重要なのはpowershell.exeの引数であり、.ps1スクリプトからではなく、Powershellプロンプト自体からではありません。私は現在、これを持っているが、それは誤りを生産している:powershell.exeの引数としてmessageboxを作成するには?
powershell.exe -Command "[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"); [System.Windows.Forms.MessageBox]::Show("Test!!!")"
私も周囲の二重引用符でとせずに、-Command
なしとInvoke-Expression
で試してみました。作成した
エラー:
At line:1 char:51
+ [System.Reflection.Assembly]::LoadWithPartialName(System.Windows.Form ...
+ ~
Missing ')' in method call.
At line:1 char:51
+ ... eflection.Assembly]::LoadWithPartialName(System.Windows.Forms); [Syst ...
+ ~~~~~~~~~~~~~~~~~~~~
Unexpected token 'System.Windows.Forms' in expression or statement.
At line:1 char:71
+ ... flection.Assembly]::LoadWithPartialName(System.Windows.Forms); [Syste ...
+ ~
Unexpected token ')' in expression or statement.
At line:1 char:114
+ ... stem.Windows.Forms); [System.Windows.Forms.MessageBox]::Show(Test!!!)
+ ~
Missing ')' in method call.
At line:1 char:114
+ ... stem.Windows.Forms); [System.Windows.Forms.MessageBox]::Show(Test!!!)
+ ~~~~~~~
Unexpected token 'Test!!!' in expression or statement.
At line:1 char:121
+ ... stem.Windows.Forms); [System.Windows.Forms.MessageBox]::Show(Test!!!)
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
二重引用符**を必要とする場合は、すべて二重引用符を使用します。 'powershell.exe -Command '... [System.Windows.Forms.MessageBox] :: Show(" "Test !!! $ PSUICulture" "") "'と同様です。 – JosefZ