LoginSignup
1
5

More than 5 years have passed since last update.

PowerShellを使ってメッセージボックスを出力

Posted at

Powershellのメッセージボックス出力をやってみた件

沢山の変数を作成して、編集しやすいようにまとめておいた。
メッセージ以降は、どういう処理がいいか人それぞれだと思い、適当に記述を行った。

#-----------------------------------------------------------------------------
#■変数名
# $CHESEN = 確認ダイアログ内の確認文言
# $CHETIT = 確認ダイアログのタイトル
# $CHEKIN = メッセージボックスの種類  ("AbortRetryIgnore","OK","OKCancel","RetryCancel","YesNo")
# $CHEICO = メッセージボックスアイコン  ("None","Information","Warning","Error")
# $CHEBUT = デフォルトのフォーカス  ("button1","button2","button3")
# $result = メッセージボックスの結果確認格納変数
#---------------------------------------------------------------------------

#■変数格納箇所
$CHESEN = "テストを行います。"
$CHETIT = "最終確認"
$CHEKIN = "OKCancel"
$CHEICO = "None"
$CHEBUT = "button1"

#-----------------------------------------------------------------------------

#メッセージボックスを出力します。
Add-Type -Assembly System.Windows.Forms
$result = [System.Windows.Forms.MessageBox]::Show("$CHESEN","$CHETIT","$CHEKIN","$CHEICO","$CHEBUT")

#メッセージボックスのハンドリング
if($result -eq 'OK'){
                   $result = "処理を開始します。"
                  } else {
                          [System.Windows.Forms.MessageBox]::show("処理を終了します。","最終確認","OK","None","button1")
                          $result = "処理終了を確認しました。"
                         }
Write-Output $result
1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5