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

Making a .js file download a file from the internet?

本文关键字:文件 一个 js 互联网 制作 下载      更新时间:2023-09-26

我有一个正在编写的批处理程序。我已经制作了一个名为"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)

工作?

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

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

如果您想使用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

@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);
}

检查一下。Will无需任何外部工具。将其保存为.bat。这应该会下载您的文件。只需更改链接和目标