17 lines
759 B
PowerShell
17 lines
759 B
PowerShell
param([Parameter(Mandatory=$true)][string]$InstallerPath)
|
|
$ErrorActionPreference = 'Stop'
|
|
$taskInstaller = (Resolve-Path -LiteralPath $InstallerPath).Path
|
|
$taskPreviousFlag = $env:YTDL_INSTALL_NONINTERACTIVE
|
|
try {
|
|
if ($taskInstaller.EndsWith('.exe', [StringComparison]::OrdinalIgnoreCase)) {
|
|
$taskProcess = Start-Process -FilePath $taskInstaller -ArgumentList '--silent' -WindowStyle Hidden -Wait -PassThru
|
|
if ($taskProcess.ExitCode -ne 0) { throw "Offline installer failed: $($taskProcess.ExitCode)" }
|
|
return
|
|
}
|
|
$env:YTDL_INSTALL_NONINTERACTIVE = '1'
|
|
& $taskInstaller
|
|
if ($LASTEXITCODE -ne 0) { throw "Helper installer failed: $LASTEXITCODE" }
|
|
} finally {
|
|
$env:YTDL_INSTALL_NONINTERACTIVE = $taskPreviousFlag
|
|
}
|