No Edge Software
  • Search results
No Edge Software

Batch file Pop-Up

Description

If you’re working in a batch file, and need some kind of user interaction in a popup window, here is a really messy and ugly way of doing it:

<!-- :: Batch section
@echo off
setlocal

echo Are you sure? 
for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "HTAreply=%%a"

if "%HTAreply%" == "y" goto :dowork
if "%HTAreply%" == "Y" goto :dowork

goto :eof

:dowork

copy /y c:\temp\input.txt c:\temp\output.txt

goto :eof

-->

<!DOCTYPE html>
<html>
  <head>
    <hta:application border="none" scroll="no">
    <style type="text/css">
      body { width: 300px; height: 300px; margin-left: 10%; margin-right: 10%; color: white; background-color: #009; }
    </style>
    <script>
       function closeHTA(reply) {
         var fso = new ActiveXObject("Scripting.FileSystemObject");
         fso.GetStandardStream(1).WriteLine(reply);
         window.close();         
       }
    </script>
  </head>
  <body>
    <p>Are you sure?</p>
    <input type="button" onclick="closeHTA('Y');" value="Yes">
    <input type="button" onclick="closeHTA('N');" value="No">
  </body>
</html>

Author

Joe Enos