如何创建带有 Yes/No 按钮和信息标记图标的弹出窗口 window?

How do I create a popup window with Yes/No buttons and a Information Mark icon?

我需要在 PowerShell 中有一个弹出窗口 window,其中包含带有是和否按钮的信息标记图标。

我目前的代码如下:

$wshell = New-Object -ComObject Wscript.Shell
  $answer = $wshell.Popup("Do you want to continue?",0,"Alert",0x4)

if($answer -eq 7){exit}

只有是或否的部分。我也需要一个图标。

你可以这样做:

$answer = $wshell.Popup("Do you want to continue?",0,"Alert",64+4)

图标values如下:

Stop          16
Question      32
Exclamation   48
Information   64

按钮的值如下:

OK               0
OKCancel         1
AbortRetryIgnore 2
YesNoCancel      3
YesNo            4
RetryCancel      5

所以信息图标和yes/no按钮是64 + 4

IMO 在这种情况下使用问题图标更有意义,因为你是在问问题而不是仅仅传达信息,所以在这种情况下它是 32 + 4。

标记到 samgak。 有多种方法可以满足您的需求。

或者这个...

[System.Windows.Forms.MessageBox]::Show("We are proceeding with next step." , "Status" , 4, 64)

或者这个...

[System.Windows.Forms.MessageBox]::Show("Continue Task?","What a Mess", "YesNo" , "Information" , "Button1")

或者这个...

[void][System.Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’) 
# [microsoft.visualbasic.interaction]::Msgbox($message,"$button,$icon",$title)
[Microsoft.VisualBasic.Interaction]::MsgBox(“Do you agree?”, ‘YesNoCancel,Information’, “Respond please”)