Batch file Pop-Up

Posted by Joe Enos on August 06, 2021 · 2 mins read

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

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


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

goto :eof


<!DOCTYPE html>
<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; }
function closeHTA(reply) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
<p>Are you sure?</p>
<input type="button" onclick="closeHTA('Y');" value="Yes">
<input type="button" onclick="closeHTA('N');" value="No">