mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +00:00
Inital commit.
This commit is contained in:
83
images/win/scripts/ImageHelpers/InstallHelpers.ps1
Normal file
83
images/win/scripts/ImageHelpers/InstallHelpers.ps1
Normal file
@@ -0,0 +1,83 @@
|
||||
function Install-MSI
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$MsiUrl,
|
||||
[String]$MsiName
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $MsiName..."
|
||||
$FilePath = "${env:Temp}\$MsiName"
|
||||
|
||||
Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath
|
||||
|
||||
$Arguments = ('/i', $FilePath, '/QN', '/norestart' )
|
||||
|
||||
Write-Host "Starting Install $MsiName..."
|
||||
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the MSI $MsiName"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Install-EXE
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$Url,
|
||||
[String]$Name,
|
||||
[String[]]$ArgumentList
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $Name..."
|
||||
$FilePath = "${env:Temp}\$Name"
|
||||
|
||||
Invoke-WebRequest -Uri $Url -OutFile $FilePath
|
||||
|
||||
Write-Host "Starting Install $Name..."
|
||||
$process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -Wait -PassThru
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host -Object 'Installation successful'
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
|
||||
return $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install the Executable $Name"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
return -1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user