28 lines
1.3 KiB
PowerShell
28 lines
1.3 KiB
PowerShell
## 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 { Write-Error $_.Exception.Message ; Exit }
|
|
|
|
## Delete installer
|
|
Try { If ( Test-Path $Installer ) { Remove-Item $Installer -Force } }
|
|
Catch { Write-Error $_.Exception.Message }
|
|
|
|
## Install manager service
|
|
Try { Start-Process "${Env:ProgramFiles}\WireGuard\wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue }
|
|
Catch { Write-Error $_.Exception.Message }
|
|
|
|
## Create shortcut on Public desktop
|
|
If ( $CreateDesktopShortcut ) {
|
|
New-Shortcut -Path "${Env:Public}\Desktop\WireGuard VPN.LNK" -TargetPath "${Env:ProgramFiles}\WireGuard\wireguard.exe" -Description "WireGuard: Fast, Modern, Secure VPN Tunnel"
|
|
}
|
|
}
|
|
Else { Write-Output "Must be an administrator to install WireGuard" } |