制作.js文件从互联网上下载文件?

时间:2014-04-20 15:57:27

标签: javascript batch-file download

我有一个我正在编码的批处理程序。我已经使它成为一个名为“filedownload.js”的文件。我需要“filedownload.js”才能下载文件

http://www.batchfilegamescontent.elementfx.com/examplefile.txt

到特定文件夹。例如;

C:\Users\%Username%\desktop\RamTach\data\

然后我需要批处理文件来运行“filedownload.js”文件。我可以使用

这样做吗?
md ".settings"
call filedownload.js

?? 在“filedownload.js”上

setTimeout(function () { window.location =    'http://www.batchfilegamescontent.elementfx.com/examplefile.txt'; }, 0)

工作?

3 个答案:

答案 0 :(得分:0)

从互联网上下载文件的最佳方法是使用名为MGet的应用程序来下载文件,它没有硬语法。 网址:http://bit.ly/1i1FpGE 语法:

MGET http://www.batchfilegamescontent.elementfx.com/examplefile.txt examplefile.txt

答案 1 :(得分:0)

@if (@X)==(@Y) @end /****** silent line that start jscript comment ******

@echo off
::::::::::::::::::::::::::::::::::::
:::       compile the script    ::::
::::::::::::::::::::::::::::::::::::
setlocal
if exist simpledownloader.exe goto :skip_compilation

set "frm=%SystemRoot%\Microsoft.NET\Framework\"
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
    if exist "%%v\jsc.exe" (
        rem :: the javascript.net compiler
        set "jsc=%%~dpsnfxv\jsc.exe"
        goto :break_loop
    )
)
echo jsc.exe not found && exit /b 0
:break_loop


call %jsc% /nologo /out:"simpledownloader.exe" "%~dpsfnx0"
::::::::::::::::::::::::::::::::::::
:::       end of compilation    ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation

:: download the file


 ::::just change the link and the file::::
 simpledownloader.exe "http://pastebin.com/raw.php?i=id7CWRHF" "target.bat"


exit /b 0


****** end of jscript comment ******/

import System;
var arguments:String[] = Environment.GetCommandLineArgs();
var webClient:System.Net.WebClient = new System.Net.WebClient();
print("Downloading " + arguments[1] + " to " + arguments[2]);
try {
    webClient.DownloadFile(arguments[1], arguments[2]);
} catch (e) {

        Console.BackgroundColor = ConsoleColor.Green;
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("\n\nProblem with downloading " + arguments[1] + " to " + arguments[2] + "Check if the internet address is valid");
        Console.ResetColor();
        Environment.Exit(5);
}

检查一下。将没有任何外部工具。将其保存为.bat。这应该下载您的文件。改变链接和目标

答案 2 :(得分:0)

如果你想使用javascript,你可以尝试使用node.js:

var http = require('http');
var fs = require('fs');

var file = fs.createWriteStream(your_path);
var request = http.get(your_url, function(response) {
  response.pipe(file);
});

然后运行node <scriptname>.js