0

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
  • 2
    Please [edit] your question to provide a [mcve] (_"not working"_ declaration does not suffice). – JosefZ Sep 10 '22 at 16:44
  • 1
    Doesn't make much sense to use `-Passthru` then pipe to `Out-Null`. – Abraham Zinala Sep 10 '22 at 17:10
  • @JosefZ done, the issue is its not even downloading wireguard .msi sometimes and if it download then it do not get install. – Vaibhav Patel Sep 10 '22 at 20:35
  • Use the [logging options](https://www.advancedinstaller.com/user-guide/msiexec.html) for msiexec.exe so you can inspect that after your code has run to see what errors occured. – Theo Sep 11 '22 at 11:26
  • Where is a piece of code for downloading a `.msi` file? – JosefZ Sep 11 '22 at 11:59
  • Before this code we are using auth token -read-host, [pscredential], GetNetworkCredential().password $source = "https://download.wireguard.com/windows-client/wireguard-amd64-0.5.3.msi" $destinationWireguard = "c:\wireguard-amd64-0.5.3.msi" # Create the new WebClient $webClient = [System.Net.WebClient]::new() # Download the wireguard file $webClient.DownloadFile($source, $destinationWireguard) – Vaibhav Patel Sep 12 '22 at 18:59
  • @JosefZ any help? – Vaibhav Patel Sep 16 '22 at 20:27

1 Answers1

0

$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>
JosefZ
  • 28,460
  • 5
  • 44
  • 83