Hi
I have been working on a PS script which contained a message box.
This all worked without issues when testing a few weeks ago, so I commented the message box part out of the script, while I was working on other things.
Now when I’m ready to test, I can’t for the science of me get the message box working again.
I have stripped out the part below:
$MsgboxTitle = 'Title' $MsgboxTxt = "Message" [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null ##This Works #[System.Windows.Forms.MessageBox]::Show($MsgboxTxt, $MsgboxTitle, [Windows.Forms.MessageBoxButtons]::YesNo, [System.Windows.Forms.MessageBoxIcon]::Stop, [System.Windows.Forms.MessageBoxDefaultButton]::Button1) ##Neither of the two below works #[System.Windows.Forms.MessageBox]::Show($MsgboxTxt, $MsgboxTitle, [Windows.Forms.MessageBoxButtons]::YesNo, [System.Windows.Forms.MessageBoxIcon]::Stop, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly) #[System.Windows.Forms.MessageBox]::Show($MsgboxTxt, $MsgboxTitle, [Windows.Forms.MessageBoxButtons]::YesNo, [System.Windows.Forms.MessageBoxIcon]::Stop, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::ServiceNotification)
When I run the snippet above with the line containing DefaultDesktopOnly or ServiceNotification, I immediately get and output on ‘No’ and no messagebox of course.
I have tried running this same snippet on Windows7/8.1/10 x64 and get the same results on them all.
The reason I am using this message box option, is that I have a service running as SYSTEM and it will run a PS script and display the messagebox to the user, which I need the users feedback(Yes or No).
I have no hair on my head left, because I have pulled them all out by now
Seriously, any help is much appreciated.
Thank you