# Download from sourceforge or fosshub (qBittorrent)

**URL:** <https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067>\
**Category:** PowerShell Help\
**Created:** [May 7, 2024, 12:27am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067 "2024-05-07T00:27:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![afbebn](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@afbebn](https://forums.powershell.org/u/afbebn)\
**Post date:** [May 7, 2024, 12:27am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/1 "2024-05-07T00:27:50Z")

</div>

Trying to download qBittorrent using powershell and all I got is:

```powershell
Invoke-WebRequest -UserAgent 'Wget' -Uri https://sourceforge.net/projects/qbittorrent/files/latest/download -OutFile $ENV:temp\qBittorrent.exe

```

Problem is that’s super slow and I would like to use

```powershell
(New-Object System.Net.WebClient).DownloadFile("INSERT-URL-HERE", "$ENV:temp\qBittorrent.exe")

```

But that’s not working because it’s Sourceforge…

These are the options to download from:

1. Fosshub: [qBittorrent download latest version](https://www.fosshub.com/qBittorrent.html)
2. Sourceforge: [qBittorrent download | SourceForge.net](https://sourceforge.net/projects/qbittorrent/)

Edit:  
Found an ugly solution:

```powershell
Write-Host 'qBittorrent > Get latest' -ForegroundColor green -BackgroundColor black
$qBitReleases = Invoke-RestMethod 'https://github.com/qBittorrent/qBittorrent/releases.atom'
$qBitLatest = ($qBitReleases.title) -replace 'release-', '' | Select-Object -First 1
$qBitURL1 = 'https://deac-fra.dl.sourceforge.net/project/qbittorrent/qbittorrent-win32/qbittorrent-'
$qBitURL3 = '/qbittorrent_'
$qBitURL5 = '_x64_setup.exe?viasf=1'
$qBitFull = $qBitURL1 + $qBitLatest + $qBitURL3 + $qBitLatest + $qBitURL5
Write-Host 'qBittorrent > Download' -ForegroundColor green -BackgroundColor black
(New-Object System.Net.WebClient).DownloadFile("$qBitFull", "$ENV:temp\qBittorrent.exe")

```

That’s really ugly, but that’s working, I would like a more simple solution if someone got any.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 12:58am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/2 "2024-05-07T00:58:40Z")

</div>

> [@afbebn](#):
>
> ```auto
> Invoke-WebRequest -UserAgent 'Wget' -Uri https://sourceforge.net/projects/qbittorrent/files/latest/download -OutFile $ENV:temp\qBittorrent.exe
> 
> ```

Define ‘too slow’. What is your expectation? That downloaded in a couple seconds for me.

also…

> [@afbebn](#):
>
> ```auto
> (New-Object System.Net.WebClient).DownloadFile("INSERT-URL-HERE", "$ENV:temp\qBittorrent.exe")
> 
> ```

this works just fine for me as well, and is a tad bit faster.

---

<div class="post-metadata">

**Author:** ![afbebn](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@afbebn](https://forums.powershell.org/u/afbebn)\
**Post date:** [May 7, 2024, 1:01am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/3 "2024-05-07T01:01:07Z")

</div>

> [@afbebn](#):
>
> Problem is that’s super slow and I would like to use

I would like to stop using

```powershell
Invoke-WebRequest

```

and only use

```powershell
(New-Object System.Net.WebClient).DownloadFile

```

> [@dotnVo](#):
>
> this works just fine for me as well, and is a tad bit faster.

Yes, it is faster, but I would like a better implementation, that’s just super ugly and it bothers me I can’t figure out how to make it better and simple.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 1:06am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/4 "2024-05-07T01:06:21Z")

</div>

You are contradicting yourself

you state you want to use

```powershell
(New-Object System.Net.WebClient).DownloadFile("INSERT-URL-HERE", "$ENV:temp\qBittorrent.exe")

```

I tell you that it works and you say its too ugly? You failed to define what you consider too slow, then you state you only want to use `(New-Object System.Net.WebClient).DownloadFile` which i originally stated works… I’m super confused.

Do you want to use it or not want to use it? You are giving conflicting information.

```powershell
$uri = 'https://sourceforge.net/projects/qbittorrent/files/latest/download'
(New-Object System.Net.WebClient).DownloadFile("$uri", "$ENV:temp\qBittorrent.exe")

```

works just fine. it takes 1 second for me to run on a home internet connection. Please clarify the ask.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 1:09am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/5 "2024-05-07T01:09:10Z")

</div>

If you want it to be more ‘simple’ write a wrapper function then call your wrapper function. but tbh, it’s pretty simple as is IMO, it’s a single method that takes two parameters.

---

<div class="post-metadata">

**Author:** ![afbebn](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@afbebn](https://forums.powershell.org/u/afbebn)\
**Post date:** [May 7, 2024, 1:10am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/6 "2024-05-07T01:10:38Z")

</div>

> [@dotnVo](#):
>
> You failed to define what you consider too slow

Sorry about that, I’ll explain.

```powershell
Invoke-WebRequest -UserAgent 'Wget' -Uri https://sourceforge.net/projects/qbittorrent/files/latest/download -OutFile $ENV:temp\qBittorrent.exe

```

Is slow on my machine, it takes 10 seconds to complete.

```powershell
Write-Host 'qBittorrent > Get latest' -ForegroundColor green -BackgroundColor black
$qBitReleases = Invoke-RestMethod 'https://github.com/qBittorrent/qBittorrent/releases.atom'
$qBitLatest = ($qBitReleases.title) -replace 'release-', '' | Select-Object -First 1
$qBitURL1 = 'https://deac-fra.dl.sourceforge.net/project/qbittorrent/qbittorrent-win32/qbittorrent-'
$qBitURL3 = '/qbittorrent_'
$qBitURL5 = '_x64_setup.exe?viasf=1'
$qBitFull = $qBitURL1 + $qBitLatest + $qBitURL3 + $qBitLatest + $qBitURL5
Write-Host 'qBittorrent > Download' -ForegroundColor green -BackgroundColor black
(New-Object System.Net.WebClient).DownloadFile("$qBitFull", "$ENV:temp\qBittorrent.exe")

```

This takes only 3 seconds.

What I would like to do is create a powershell script that downloads the latest (non-beta) version of qBittorrent from sourceforge.  
Which is another thing - I have to make sure it doesn’t catch the beta versions.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 1:20am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/7 "2024-05-07T01:20:03Z")

</div>

Just to be clear, we’re here to help with scripts, not write them for others. If you’re looking for someone to write you a script, you’ll want to engage with fiver or another paid service.

That said, this is mostly straight forward with a wrapper command, as previously mentioned.

```powershell
function Get-BitTorrent {
    param (
        [string]$URI = 'https://sourceforge.net/projects/qbittorrent/files/latest/download',
        [string]$Location = "$env:temp\qbittorrent.exe"
    )
    (New-Object System.Net.WebClient).DownloadFile("$uri", "$Location") 
}

```

This is something I wrote in like 5-6 seconds. Then you can call `Get-BitTorrent`, and if you don’t provide any parameters, it’ll use the default parameters… Note that for each session you need to ‘load’ that function in your session, so it’s probably best to add it to your PS Profile. See: [about Profiles - PowerShell | Microsoft Learn](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4)

If you don’t want to catch the beta versions, you’ll want to try to code that in. I don’t have any knowledge on how their releases are done, and whether they use different sources for different things.

Also, another option you can consider is using a package manager, such as chocolatey: [Chocolatey Software | Chocolatey - The package manager for Windows](https://chocolatey.org/)

while the free version is community driven, they probably keep that up to date : [Chocolatey Software | qBittorrent 4.6.4](https://community.chocolatey.org/packages/qbittorrent). It has the added benefit of installing it in the same step, and you can easily update.

---

<div class="post-metadata">

**Author:** ![afbebn](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@afbebn](https://forums.powershell.org/u/afbebn)\
**Post date:** [May 7, 2024, 1:24am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/8 "2024-05-07T01:24:14Z")

</div>

> [@dotnVo](#):
>
> ```auto
> function Get-BitTorrent {
> param (
> [string]$URI = 'https://sourceforge.net/projects/qbittorrent/files/latest/download',
> [string]$Location = "$env:temp\qbittorrent.exe"
> )
> (New-Object System.Net.WebClient).DownloadFile("$uri", "$Location") 
> }
> 
> ```

I see you did not try it, because as I already said on my first post:

> But that’s not working because it’s Sourceforge…

If there’s a possible way to pass it a user-agent the same way the first command uses, then it will work, which I haven’t found a way.

> [@dotnVo](#):
>
> chocolatey

But… I don’t want to use chocolatey, I created a powershell script…  
Also - I am familiar with chocolatey…

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 2:08am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/12 "2024-05-07T02:08:54Z")

</div>

After some clarification via DMs, the issue was that while a file was downloading - it was not the actual installer.

This is because sourceforge requires Wget user agent for a ‘direct’ download that also attempts to grab the latest version.

```powershell
function Get-BitTorrent {
    param (
        [string]$URI = 'https://sourceforge.net/projects/qbittorrent/files/latest/download',
        [string]$Location = "$env:temp\qbittorrent.exe"
    )
    $WebClient = New-Object System.Net.WebClient
    $WebClient.Headers.Add('user-agent','Wget')
    $WebClient.DownloadFile("$uri", "$Location")
}

```

Defining the user agent in the webclient appears to resolve the issue.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 7, 2024, 2:20am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/13 "2024-05-07T02:20:13Z")

</div>

Closed on May 7, 2024, 2:20am UTC



---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [May 7, 2024, 5:18am UTC](https://forums.powershell.org/t/download-from-sourceforge-or-fosshub-qbittorrent/24067/14 "2024-05-07T05:18:55Z")

</div>

I want to offer a different alternative. It does require two calls

```auto

function Get-BitTorrent {
    param (
        [string]$URI = 'https://sourceforge.net/projects/qbittorrent/files/latest/download',
        [string]$Location = "$env:temp\qbittorrent.exe"
    )
    $output = Invoke-WebRequest $URI -UseBasicParsing
    $link = $output.links.'data-release-url' | Select-Object -First 1
    Invoke-WebRequest $link -UseBasicParsing -OutFile $Location
}

```

It is faster than using Invoke-WebRequest with the wget agent, but you can also use the webclient instead.

```auto
function Get-BitTorrent {
    param (
        [string]$URI = 'https://sourceforge.net/projects/qbittorrent/files/latest/download',
        [string]$Location = "$env:temp\qbittorrent.exe"
    )
    $output = Invoke-WebRequest $URI -UseBasicParsing
    $link = $output.links.'data-release-url' | Select-Object -First 1
    $webclient = New-Object System.Net.WebClient
    $webclient.DownloadFile("$link", "$Location")
}

```
