Using MsgBox Dialogs

by Dec 10, 2010

Have you ever used VBScript? Would you like your MsgBox dialog back? Here is how:

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$rv = [Microsoft.VisualBasic.Interaction]::MsgBox('Do you want this to happen?', `
'YesNoCancel, Exclamation,MsgBoxSetForeground,SystemModal', 'Accept or Deny')
Switch ($rv) {
'Yes' { "OK, we'll do it!" }
'No' { "Next time maybe…" }
'Cancel' { "you cancelled…"}
}

Twitter This Tip!
ReTweet this Tip!