lib/.playwright/package/bin/reinstall_msedge_dev_win.ps1

$ErrorActionPreference = 'Stop'
$url = $args[0]

Microsoft.PowerShell.Utility\Write-Host "Downloading Microsoft Edge Dev"
$wc = Microsoft.PowerShell.Utility\New-Object net.webclient
$msiInstaller = "$env:temp\microsoft-edge-dev.msi"
$wc.Downloadfile($url, $msiInstaller)

Microsoft.PowerShell.Utility\Write-Host "Installing Microsoft Edge Dev"
$arguments = "/i `"$msiInstaller`" /quiet"
Microsoft.PowerShell.Management\Start-Process msiexec.exe -ArgumentList $arguments -Wait
Microsoft.PowerShell.Management\Remove-Item $msiInstaller

$suffix = "\\Microsoft\\Edge Dev\\Application\\msedge.exe"
if (Microsoft.PowerShell.Management\Test-Path "${env:ProgramFiles(x86)}$suffix") {
    (Microsoft.PowerShell.Management\Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Microsoft.PowerShell.Management\Test-Path "${env:ProgramFiles}$suffix") {
    (Microsoft.PowerShell.Management\Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
    Microsoft.PowerShell.Utility\Write-Host "ERROR: Failed to install Microsoft Edge Dev."
    Microsoft.PowerShell.Utility\Write-Host "ERROR: This could be due to insufficient privileges, in which case re-running as Administrator may help."
    exit 1
}