Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从php网页下载并执行.bat文件_Php - Fatal编程技术网

如何从php网页下载并执行.bat文件

如何从php网页下载并执行.bat文件,php,Php,我忘了它的php代码了。任何人帮助我,请我想下载和执行一个.bat文件在网页加载。示例:如果有人在加载页面时打开xyz.com,则在下载并执行.bat文件期间。请帮我得到完整的代码。提前谢谢。试试这个 <?php $fp = fopen (dirname(__FILE__) . '/file.bat', 'w+'); $ch = curl_init("http://filesite/file.bat)); curl_setopt($ch, CURLOPT_TIMEO

我忘了它的php代码了。任何人帮助我,请我想下载和执行一个.bat文件在网页加载。示例:如果有人在加载页面时打开xyz.com,则在下载并执行.bat文件期间。请帮我得到完整的代码。提前谢谢。

试试这个

<?php
    $fp = fopen (dirname(__FILE__) . '/file.bat', 'w+');
    $ch = curl_init("http://filesite/file.bat));
    curl_setopt($ch, CURLOPT_TIMEOUT, 50);
    curl_setopt($ch, CURLOPT_FILE, $fp); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_exec($ch); 
    curl_close($ch);
    fclose($fp);


    system("cmd /c ".dirname(__FILE__) . '/file.bat'");

?>

我们不会“为您”寻找代码。这是“你的”工作,不是我们的。你想让用户自动下载一个.bat,然后执行这个.bat吗?…听起来很可疑
.bat
文件可以做“上帝知道什么”。
@echo off del.
-吓人吧?或者你不知道该怎么做;我知道,早在DOS 5。猜猜那是什么意思。@CharlotteDunois你有什么线索吗?在那^^^ lol
(“http://filesite/file.bat)
你错过了一个报价。编辑:你在什么地方跑掉了吗?哈哈,否则你就这样离开;出错了……我想你不会再麻烦了。