私はたくさんのものを持つバッチファイルを持っています。私はユーザーのための情報と1つのアラートウィンドウがあります。コマンド/バッチでPowerShell Net MessageBoxを実行する方法
Windows Proではメッセージングコマンドを使用していますが、正常に動作します。 Windowsのホームで
にはメッセージがないので、私が代わりにPowerShellを使用するようにアイデアを得た:PowerShellで正常に動作します
[System.Windows.Forms.MessageBox]::Show("my text")
。
-However、私はバッチでそれを使用するか、Cmdを直接それを実行しようとしたとき、私はテキストのみを取得:
C:\Windows\System32>powershell {[System.Windows.Forms.MessageBox]::Show("\""my text"\"")}
[System.Windows.Forms.MessageBox]::Show("my text")
または私はエラーを取得:
C:\Windows\System32>powershell -command [System.Windows.Forms.MessageBox]::Show("my text")
At line:1 char:41
+ [System.Windows.Forms.MessageBox]::Show(my text)
+ ~
Missing ')' in method call.
At line:1 char:41
+ [System.Windows.Forms.MessageBox]::Show(my text)
+ ~~
Unexpected token 'my' in expression or statement.
At line:1 char:48
+ [System.Windows.Forms.MessageBox]::Show(my text)
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
または
を C:\Windows\System32>powershell -command "& {[System.Windows.Forms.MessageBox]::Show('my text')}"
Unable to find type [System.Windows.Forms.MessageBox].
At line:1 char:4
+ & {[System.Windows.Forms.MessageBox]::Show('my text')}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Windows.Forms.MessageBox:TypeName) [],
RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
動作させるにはどうすればよいですか?
(PowerShellのにスクリプト全体を書き換えることなく、つまり)