0

インターフェイスとしてphpファイルがあり、押すボタンが3つあります。1 番目と 2 番目のボタンは、スケジューラ バッチ ファイルによって生成されるダウンロード リンクに誘導されます。3番目のボタンをクリックするとrun.phpが呼び出されますが、バッチファイルを手動で実行して、ファイルの最新の更新を取得します。

問題: ローカルホストで試したとき、div の "statusNow" は、scheduler.bat ファイルが完全に実行されたときに "進行中、お待ちください" から "完了" にしか変わりません。

しかし、ファイルをLifeサーバーに入れると、バッチファイルが完全に実行される前(基本的に最初のxcopyコマンドの後)、ステータスが既に完了に変更されます。

<!DOCTYPE html>
<html>
<head>
<script>
function dothework()
{
var xmlhttp;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("statusNow").innerHTML="Completed";
    document.getElementById("b1").disabled=false;
    document.getElementById("b2").disabled=false;
    document.getElementById("b3").disabled=false;
    }
  }
xmlhttp.open("GET","run.php",true);
xmlhttp.send();
document.getElementById("b1").disabled=true;
document.getElementById("b2").disabled=true;
document.getElementById("b3").disabled=true;
document.getElementById("statusNow").innerHTML="Please wait... In the progess...";
}
</script>
</head>
<body>

<form>
<button type="button" id="b1" onclick="window.location.href='downloadlink1'"</button>
<button type="button" id="b2" onclick="window.location.href='downloadlink2'"</button>
<br><br>

<button type="button" id="b3" onclick="dothework()">Export</button>
<div id="statusNow"><h2></h2></div>
</form>

</body>
</html>

ここにphpファイルがあります

<?php
system("cmd /c C:\scheduler.bat");
?>

スケジューラーファイル

@echo off

xcopy C:afile C:download\afile /s /e /i /y

cd C:download\
"C:\Program Files\WinRAR\Rar.exe" a -df -r "afile.rar" "afile"

xcopy C:bfile C:download\bfile /s /e /i /y

cd C:download\
"C:\Program Files\WinRAR\Rar.exe" a -df -r "bfile.rar" "bfile"
4

0 に答える 0