Answer the question
In order to leave comments, you need to log in
How to add destination folder when downloading in JavaScript?
I'm not into programming, but recently the task arose - by launching a file (the same .wsf) to ensure that the desired object is downloaded via a direct link. Since this is not possible through the standard Windows console, I found a working javascript code on the Internet, but it lacks a destination folder, i.e. folder where the file will be downloaded. By default, the file is placed on the desktop, but how can I specify a specific folder?
<job>
<script language="JScript">
httpGet("http://forum.ixbt.com/bbtitle-ixbt.gif");
function httpGet(url)
{
var fname=url.replace(/.+\//,"");
with(new ActiveXObject("WinHttp.WinHttpRequest.5.1"))
{
open("GET",url);
send();
if(status==200)
with(new ActiveXObject("ADODB.Stream"))
{
type=1;
open();
write(responseBody);
saveToFile(fname,2);
}
}
}
</script>
</job>
Answer the question
In order to leave comments, you need to log in
var fname=url.replace(/.+\//,"");
fname = 'd:\\path\\to\\file\\' + fname;
wget -P d:\path http://site.com/file.rar
install curl, wget or the whole cygwin and enjoy. Also powershell can do it for sure. well, in this case, specify the full file name as the saveToFile argument.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question