|
145 | 145 | ```
|
146 | 146 |
|
147 | 147 | **Error Behavior:** `ON_ERROR_CANCEL`
|
| 148 | +
|
| 149 | +### Windows PowerShell examples |
| 150 | +#### GUI message box on error condition |
| 151 | +The message box stays on screen until acknowledged by the user. Use the same script for both backup plan and repo settings to catch errors. |
| 152 | +
|
| 153 | +**Condition** `CONDITION_ANY_ERROR` |
| 154 | +
|
| 155 | +**Script** |
| 156 | +```powershell |
| 157 | +Add-Type -AssemblyName System.Windows.Forms |
| 158 | +# This option puts message box on top of all windows. |
| 159 | +$options = [System.Windows.Forms.MessageBoxOptions]::ServiceNotification |
| 160 | +$defbutton = [System.Windows.Forms.MessageBoxDefaultButton]::Button1 |
| 161 | +$buttons = [System.Windows.Forms.MessageBoxButtons]::OK |
| 162 | +$icon = [System.Windows.Forms.MessageBoxIcon]::Error |
| 163 | +$title = "Backrest" |
| 164 | +$message = '{{ .Summary }}' |
| 165 | +[System.Windows.Forms.MessageBox]::Show($message, $title, $buttons, $icon, $defbutton, $options) |
| 166 | +
|
| 167 | +# Include this comment and the line above it. See https://github.com/garethgeorge/backrest/issues/400 |
| 168 | +``` |
| 169 | +#### GUI toast warning notification |
| 170 | +Toast or app notifications appear for a short time before disappearing without user acknowledgement. |
| 171 | +
|
| 172 | +**Condition** `CONDITION_SNAPSHOT_WARNING` |
| 173 | +
|
| 174 | +**Script** |
| 175 | +```powershell |
| 176 | +Add-Type -AssemblyName System.Windows.Forms |
| 177 | +$balloon = New-Object System.Windows.Forms.NotifyIcon |
| 178 | +$balloon.Icon = [System.Drawing.SystemIcons]::Warning |
| 179 | +$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning |
| 180 | +$balloon.BalloonTipText = '{{ .Summary }}' |
| 181 | +$balloon.BalloonTipTitle = "Backrest" |
| 182 | +$balloon.Visible = $true |
| 183 | +$balloon.ShowBalloonTip(5000) |
| 184 | +Start-Sleep -Seconds(5) |
| 185 | +$balloon.Visible = $false |
| 186 | +$balloon.Icon.Dispose() |
| 187 | +$balloon.Dispose() |
| 188 | +
|
| 189 | +# Include this comment and the line above it. See https://github.com/garethgeorge/backrest/issues/400 |
| 190 | +``` |
| 191 | +#### GUI toast information notification |
| 192 | +
|
| 193 | +**Condition** `CONDITION_SNAPSHOT_SUCCESS` |
| 194 | +
|
| 195 | +**Script** |
| 196 | +```powershell |
| 197 | +Add-Type -AssemblyName System.Windows.Forms |
| 198 | +$balloon = New-Object System.Windows.Forms.NotifyIcon |
| 199 | +$balloon.Icon = [System.Drawing.SystemIcons]::Information |
| 200 | +$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Information |
| 201 | +$balloon.BalloonTipText = '{{ .Summary }}' |
| 202 | +$balloon.BalloonTipTitle = "Backrest" |
| 203 | +$balloon.Visible = $true |
| 204 | +$balloon.ShowBalloonTip(5000) |
| 205 | +Start-Sleep -Seconds(5) |
| 206 | +$balloon.Visible = $false |
| 207 | +$balloon.Icon.Dispose() |
| 208 | +$balloon.Dispose() |
| 209 | +
|
| 210 | +# Include this comment and the line above it. See https://github.com/garethgeorge/backrest/issues/400 |
| 211 | +``` |
0 commit comments