This project is read-only.

Show-DialogBox response variable

Topics: Archive - Deployment Scripts, Archive - General, Archive - Toolkit Extensions
Mar 11, 2015 at 11:05 PM

I am trying to make a condition using Show-DialogBox (OkCancel). Basically user will be asked whether user would like to proceed with the installation. If user presses "OK" button it will continue with the installation otherwise "Cancel" will force the installation to exit.

Anybody knows what the response/return variable of Show-DialogBox that I can use as "keyword" of the condition. I have tried to use $switch or $response without success.

Thanks in advance.
Mar 12, 2015 at 5:20 PM

You could just stick the returned string into a variable and evaluate it.
All Show-DialogBox return values can be found in the Write-Output calls in the Show-DialogBox function code.

Something like this:
$RUserChoice = Show-DialogBox -Title 'Installation Notice' -Text 'Installation will take approximately 30 minutes. Do you wish to proceed?' -Buttons 'OKCancel' -DefaultButton 'Second' -Icon 'Exclamation' -Timeout 600

If($RUserChoice -eq 'Cancel') {
    Exit-Script -ExitCode 5000
Marked as answer by PshellFan on 3/12/2015 at 4:03 PM
Mar 13, 2015 at 12:03 AM
Thank you so much, Marco.

This is what I am looking for. It works great.