delay a batch file in under a second?

后端 未结 6 1904
渐次进展
渐次进展 2020-12-01 18:59

Is there any way to delay a batch file in under a second, for example 10 milliseconds?

I have tried to write this:

ping localhost -n 1 -w 10
<         


        
6条回答
  •  生来不讨喜
    2020-12-01 19:43

    Here's how!


    1. Here's an image of it
    2. If that link didn't work try this

      pathping 127.0.0.1 -n -q 1 -p 100 >nul

    I recommend using localhost instead, pathping localhost -n -q 1 -p 100 >nul!

    Or try timeout %seconds% /nobreak >nul && pathping localhost -n -q 1 -p %extra% >nul to wait %seconds% seconds, and %extra% amount of time


    The && means to put two codes on 1 line, acting like 2 lines!

    But || means to run the first code, if that fails run the second code too, but if the first code succeeds then don't run the second code

    And you can group code with (%code%)

    So (%code1%)||(%code2%&&%code3%) means to run %code1%, if that fails run %code2% and %code3% after that!


    Here is a "quick" snippet I made, on how it works:

    var a=document.getElementById("countdown");
    var b=document.getElementById("full");
    var c=document.getElementById("text");
    var e=document.getElementById("timeout");
    function end(){
      if(!d){
        c.innerHTML="press CTRL+C to stop"
        a.innerHTML="10";
        e.innerHTML="/nobreak"
        d=true;
      }else{
        b.remove();
      }
    }
    var d=false;
    setInterval(function(){
      try{
        if(a.innerHTML<=0){
          end();
        }
        a.innerHTML=a.innerHTML>0?a.innerHTML-1:a.innerHTML;
      }catch(err){}
    },1000);
    
    > timeout 10 
    Waiting for 10 seconds, press to continue . . .


    • (I don't know what measurement of time %extra% is in)

提交回复
热议问题