Wireguard powershell script not working only on Windows 7, rest windows OS working fine

441 Views Asked by At

I am using following code to download Wireguard .msi version, installing and creating tunnel with .conf file but the issue is its not working on Windows 7.

Basically When I execute PowerShell Script on Windows 7 the issue is its not even downloading wireguard .msi sometimes and if it download then it do not get install.

Start-Process msiexec.exe -ArgumentList '/q', '/I', 'wireguard-amd64-0.5.3.msi' -Wait -NoNewWindow -PassThru | Out-Null
Start-Process 'C:\Program Files\WireGuard\wireguard.exe' -ArgumentList '/uninstallmanagerservice' -Wait -NoNewWindow -PassThru | Out-Null
Start-Process 'C:\Program Files\WireGuard\wireguard.exe' -ArgumentList '/installtunnelservice', "$destinationConf" -Wait -NoNewWindow -PassThru | Out-Null
1

There are 1 best solutions below

0
JosefZ On

$source = "download.wireguard.com/windows-client/wireguard-amd64-0.5.3.msi" defines a local path. Use https:// prefix to define a web source.

Self-explained by running following script:

$source = "download.wireguard.com/windows-client/wireguard-amd64-0.5.3.msi"
$destinationWireguard = ".\wireguard-amd64-0.5.3.msi"
$webClient = [System.Net.WebClient]::new()
$webClient.DownloadFile($source, $destinationWireguard)

$source = "https://download.wireguard.com/windows-client/wireguard-amd64-0.5.3.msi"
$webClient.DownloadFile($source, $destinationWireguard)

Get-Item $destinationWireguard | Select-Object -ExpandProperty FullName

Result (note the self-explaining error message):

PS D:\PShell> D:\PShell\SO\73673275.ps1
Exception calling "DownloadFile" with "2" argument(s): "Could not find a part of the
path 'D:\PShell\download.wireguard.com\windows-client\wireguard-amd64-0.5.3.msi'."
At D:\PShell\SO\73673275.ps1:4 char:1
+ $webClient.DownloadFile($source, $destinationWireguard)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

D:\PShell\wireguard-amd64-0.5.3.msi
PS D:\PShell>