php带参数调用外部程序参数传递失败

最近在做一个php html结合的多线程下载器,程序还没做完。

php(版本:5.5.9nts):

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="pragma" content="no-cache">
        <title>myidm下载器</title>
        <style>
            #err{
                color: red;
            }
        </style>
    </head>
    <body>
        <form action="" enctype="application/x-www-form-urlencoded" method="get" target="_self">
            <span>请输入下载源:&nbsp;&nbsp;&nbsp;</span><input type="text" placeholder="在此键入指定文件的url" name="url" id="url">
            <br>
            <span>请输入下载位置:&nbsp;&nbsp;&nbsp;</span><input type="text" placeholder="在此键入下载路径" name="d" id="d">
            <br>
            <input type="submit" value="开始下载">
        </form>
        <span id="err"></span>
        <!-- submit -->
        <?php
        $firsterrline = 0;
        if (isset($_GET["url"]) and isset($_GET["d"])) {
            echo "<script>document.getElementById(\"url\").value=\"" . $_GET["url"] . "\";</script>";
            echo "<script>document.getElementById(\"d\").value=\"" . $_GET["d"] . "\";</script>";
            @fclose(fopen($_GET["url"], "r"));
            if (error_get_last()["line"] != null) {
                $firsterrline = error_get_last()["line"];
                echo "<script>document.getElementById(\"err\").innerHTML=\"指定源不存在\"</script>";
                exit(1);
            }
            @chdir($_GET["d"]);
            if (error_get_last()["line"] != $firsterrline) {
                echo "<script>document.getElementById(\"err\").innerHTML=\"指定目标不存在\"</script>";
                exit(1);
            }
            ini_set("max_execution_time", "36000");
            if (get_headers($_GET["url"],true)["Content-Length"] < 30000000) {
                copy($_GET["url"], $_GET["d"] . "/" . array_reverse(explode("/", $_GET["url"]))[0]);
            }else{
                $auto = [floor(get_headers($_GET["url"],true)["Content-Length"] / 30000000), get_headers($_GET["url"],true)["Content-Length"] % 30000000];
                $openfile = fopen($_GET["url"], "r");
                $vbs = "\"" . dirname(__FILE__) . "/write.vbs\"";
                $write = "";
                $filepath = "";
                for ($i = 0; $i < $auto[0];$i++){
                    $write = "\"".fread($openfile, 30000000)."\"";
                    $filepath = "\"" . dirname(__FILE__) . "/DownloadTemp/download$i.dt\"";
                    `wscript.exe  $vbs $write $filepath`;
                }
                $write = "\"".fread($openfile, $auto[1])."\"";
                $filepath = "\"" . dirname(__FILE__) . "/DownloadTemp/downloaddone.dt\"";
                `wscript.exe $vbs $write $filepath`;
            }
        }
        ?>
    </body>
</html>


wscript.exe $vbs $write $filepath;这一行中,对于write.vbs来说传递了两个参数,实际却只传递了一个。
这一行已经尝试替换成system() exec() popen(),无果

write.vbs:

if WScript.Arguments.Count<>2 then WScript.Quit 1
CreateObject("Wscript.shell").run "cmd /c echo "&WScript.Arguments(0)&">"&Chr(34)&WScript.Arguments(1)&Chr(34),0,False
WScript.Quit 0

(作用:避免php程序阻塞,实现多线程下载)

php.ini中safe_mode已设为off disable_functions已设为 空

不知道为什么,就是不行

符號需要對稱。適當的空格有助於閱讀。

rem "&Chr(34)&" == double quote ("), must be pair
CreateObject("Wscript.shell").run "cmd /c echo "&WScript.Arguments(0)&"> "&Chr(34)&""&WScript.Arguments(1)&""&Chr(34)&",0,False "

我发现:当文件是一个不换行的文件就没事