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.
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.
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”)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With