Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I need to have a popup window in PowerShell that has the information mark icon with yes & no buttons.

My current code is as follows:

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

if($answer -eq 7){exit}

With only the yes or no part. I need an icon there too.

like image 763
M. Simon Avatar asked Dec 18 '22 00:12

M. Simon


2 Answers

You can do it like this:

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

The values for the icons are as follows:

Stop          16
Question      32
Exclamation   48
Information   64

The values for the buttons are as follows:

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

So information icon and yes/no buttons is 64 + 4

IMO in this situation it makes more sense to use a question icon since you are asking a question rather than just conveying information so it would be 32 + 4 in that case.

like image 136
samgak Avatar answered May 13 '23 09:05

samgak


Tagging on to samgak. There are a number of ways to do what you are after.

Or this...

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

Or this...

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

Or this...

[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”) 
like image 37
postanote Avatar answered May 13 '23 09:05

postanote