batch bitstransfer url with white spaces

0

I have a batch file. I use it to download installers (vlc.exe, VC++ 2008 redistributable package vcredist_x86.exe, etc) from web. Recently I downloaded VC++ 2008 redistributable package and it worked fine with this syntax:

Import-Module BitsTransfer; Start-BitsTransfer '%URL%' '%downloadPath%'

I set the VC++ 2008 download link in URL and C:\Temp in downloadPath.

I have heard on other forums about using wget and curl but I would still like to use Start-BitsTransfer.

Now the problem is when I tried to download WAMP (from WAMP website which redirects to sourceforge.net website) using this same syntax I get the error

ERROR CODE: 0x80190194 - HTTP status 404: The requested URL does not exist

After much poking at the URL I saw that the WAMP download url has /WampServer%202/Wampserver%202.5/ (I guess for single white space). So when the Start-BitsTransfer executes this, I am guessing it some how messes up the url (I am not sure how).

Can someone tell me with example code how to download WAMP using this syntax Import-Module BitsTransfer; Start-BitsTransfer '%URL%' '%downloadPath%'?

Or can someone tell me with example code how to download WAMP using PowerShell?

powershell
batch-file
asked on Stack Overflow Jul 26, 2015 by Abhijeet • edited Jul 26, 2015 by wOxxOm

1 Answer

2

% are used to expand variables in batch file language, so you have to escape each % inside the url by doubling it:

/WampServer%%202/Wampserver%%202.5/
answered on Stack Overflow Jul 26, 2015 by wOxxOm

User contributions licensed under CC BY-SA 3.0