planelover390
planelover390

Reputation: 11

Cmd prompt timer window popup

How can one get a message window to open that has a timer using a batch file? I'm trying to make a batch file that opens command prompt, and after doing 2 commands a message pops up with a timer, that says Self-Destruct in ...then plays a sound, then closes Here is what I have so far

:cmd
set /p cmd=command:

%cmd%
echo.
goto  cmd2

:cmd2

set /p cmd=command:

%cmd%
echo.

Upvotes: 1

Views: 2220

Answers (1)

npocmaka
npocmaka

Reputation: 57262

try this - it accepts only one argument - the seconds to countdown.Should be saved with .bat extension:

<!-- :
:: countdown.bat
@echo off

if "%~1" equ "" (
  echo seconds not passed
  exit /b 1
)

echo %*|mshta.exe "%~f0"|more



exit /b %errorlevel%
-->

<html>
<head><title>It's the final countdown</title></head>
<body>

<p>Seconds left</p>
<div id="countdown">--</div>
<button onclick='quit()'>QUIT</button>
    <script language='javascript' type="text/javascript">
        function parse() {
               var seconds=0;
               try {
                  var fso2= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0);
                  argline=fso2.ReadLine();
                  var args=argline.split(" ");
                  var seconds=parseInt(args[0]);
                  //var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1);
                  //fso.Write("wait for: " + milliseconds);
               } catch (err) {
                  errmessage = "cannot get the milliseconds";
                  var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1);
                  fso.Write(errmessage);
                  close();
               }
               seconds = document.getElementById('countdown').innerHTML=seconds;
               countdown();
        }

  var seconds;
  var temp;

  function countdown() {
    seconds = document.getElementById('countdown').innerHTML;
    seconds = parseInt(seconds, 10);

    if (seconds == 1) {
      temp = document.getElementById('countdown');
      close();
      //return;
    }

    seconds--;
    temp = document.getElementById('countdown');
    temp.innerHTML = seconds;
    timeoutMyOswego = setTimeout(countdown, 1000);
  } 

  //countdown();
  window.resizeTo(400,250)
  parse();

        function quit() {
            close();
        }
        //itsTheFinalCountdown(10000);
    </script>
</body>

</html>

Upvotes: 2

Related Questions