## Create a desktop shortcut for WireGuard?
$CreateDesktopShortcut = $true

## Make sure we have an administrative token
If ( IsAdmin )
{
    If ( Is64bit ) { $URL = 'https://download.wireguard.com/windows-client/wireguard-amd64-latest.msi' }
    Else           { $URL = 'https://download.wireguard.com/windows-client/wireguard-x86-latest.msi' }

    ## Install package
    $Installer = Download-File -URL $URL
    Try { Start-Process "msiexec.exe" -ArgumentList "/i ${Installer} /qn /norestart DO_NOT_LAUNCH=1" -Wait -ErrorAction Stop }
    Catch { LogErr $_.Exception.Message ; Exit }

    ## Delete installer
    Try { If ( Test-Path $Installer ) { Remove-Item $Installer -Force } }
    Catch { LogErr $_.Exception.Message }

    ## Install manager service
    Try { Start-Process "${Env:ProgramFiles}\WireGuard\wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue }
    Catch { LogErr $_.Exception.Message }

    ## Create shortcut on Public desktop
    If ( $CreateDesktopShortcut ) {
        Create-Shortcut -Path "${Env:Public}\Desktop\WireGuard VPN.LNK" -TargetPath "${Env:ProgramFiles}\WireGuard\wireguard.exe" -Description "WireGuard: Fast, Modern, Secure VPN Tunnel"
    }
}
Else { LogMsg "Must be an administrator to install WireGuard" }