简体   繁体   English

如何在Windows命令提示符下增加命令行参数的大小或限制

[英]How do I increase command line argument size or limit in windows command prompt

Hi I have created a JAVA program which uses ProcessBuilder to start command prompt, java passes command with some arguments to the console and then command prompt is responsible to handle the command, everything is working fine until the command line argument is too long. 嗨,我创建了一个JAVA程序,该程序使用ProcessBuilder启动命令提示符,java将带有一些参数的命令传递给控制台,然后命令提示符负责处理该命令,直到命令行参数过长为止,一切工作正常。 Actually I am using phantomjs as a command and passing multiple urls as a arguments to the command prompt. 实际上,我使用phantomjs作为命令,并将多个url作为参数传递给命令提示符。 Eg: Java generated string- 例如:Java生成的字符串-

phantomjs download.js --url=http://google.com, http://yahoo.com, http://website.com..................http://demo.com

When I was passing 100's of urls then it works fine but when increases to 1000's of urls then its not working. 当我传递100个URL时,它可以正常工作,但是当增加到1000个URL时,则它不起作用。 I know, it happens because of argument buffer size. 我知道,发生这种情况的原因是参数缓冲区的大小。 When I was trying to pass 1000's urls then it exceeds the maximum byte limit of the command line for windows. 当我尝试传递1000个URL时,它超过了Windows命令行的最大字节数限制。 So there is any other way to pass this value into file or can we increase the limit of command line arguments. 因此,可以通过其他任何方式将此值传递到文件中,或者我们可以增加命令行参数的限制。

Please give me some solution for this. 请给我一些解决方案。

Why not just passing a filename as argument ? 为什么不只是将文件名作为参数传递呢? The target file contains the list of urls (JSON.stringify or simply one per line) 目标文件包含网址列表(JSON.stringify或每行仅一个)

For example 例如

var system = require('system');
var fs = require('fs');
var args = system.args;

if (args.length === 1) {
  console.log('download.js <filename>');
  phantom.exit(1);
} else {
    var filename = args[1];
    var stream = fs.open(filename, 'r') 

    var line;
    while(line=stream.readLine()) {
        //do want you want here
        console.log(line);
    }

    phantom.exit(0);
}

Run with 与运行

>phantomjs download.js mytestfile.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM