Skip to content

O&O ShutUp10++ - Run

functions/public/Invoke-WPFOOSU.ps1
 1function Invoke-WPFOOSU {
 2    if ($sync.ProcessRunning) {
 3        Show-WinUtilMessage -Message "Another process is currently running." -Title "WinUtil" -Button "OK" -Icon "Warning"
 4        return
 5    }
 6
 7    $downloadPath = Join-Path $sync.winutildir "ooshutup10.exe"
 8    $sync.ProcessRunning = $true
 9
10    Invoke-WPFRunspace -ParameterList @(,("downloadPath", $downloadPath)) -ScriptBlock {
11        param($downloadPath)
12
13        $hasUI = $null -ne $sync.Form -and $null -ne $sync.Form.Dispatcher
14
15        try {
16            Write-WinUtilLog -Component "OOSU" -Message "Downloading O&O ShutUp10++."
17            if ($hasUI) {
18                Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Downloading O&O ShutUp10++ (0%)" -Percent 0
19            }
20
21            Save-WinUtilFile -Uri "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -DestinationPath $downloadPath -ProgressCallback {
22                param($percent)
23
24                if ($hasUI) {
25                    Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Downloading O&O ShutUp10++ ($percent%)" -Percent $percent
26                }
27            }
28
29            if ($hasUI) {
30                Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Launching O&O ShutUp10++" -Percent 100
31            }
32            Start-Process -FilePath $downloadPath
33
34            Write-WinUtilLog -Component "OOSU" -Message "O&O ShutUp10++ launched."
35            if ($hasUI) {
36                Set-WinUtilTweaksProgressIndicator -Visible $true -Label "O&O ShutUp10++ launched" -Percent 100
37            }
38        }
39        catch {
40            Write-WinUtilLog -Level "ERROR" -Component "OOSU" -Message "O&O ShutUp10++ download failed: $($_.Exception.Message)"
41            if ($hasUI) {
42                Set-WinUtilTweaksProgressIndicator -Visible $true -Label "O&O ShutUp10++ download failed" -Percent 100
43            }
44            Write-Error "Couldn't download O&O ShutUp10. Please make sure you have an active Internet connection."
45        }
46        finally {
47            $sync.ProcessRunning = $false
48        }
49    }
50}