I have 3 batch files. One of them requires input from the user. I wonder how I can have a GUI with 3 buttons (1 for each batch file) and a textbox for user entry which will be used by one of the batch files?
I'm trying to use this answer to make it as shown below:
<!-- :: Batch section
@echo off
setlocal
echo Select an option:
for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "HTAreply=%%a"
echo End of HTA window, reply: "%HTAreply%"
goto :EOF
-->
<HTML>
<HEAD>
<HTA:APPLICATION SCROLL="no" SYSMENU="no" >
<body bgcolor="cyan">
<TITLE>HTA Buttons</TITLE>
<SCRIPT language="JavaScript">
window.resizeTo(374,100);
function closeHTA(reply){
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.GetStandardStream(1).WriteLine(reply);
window.close();
}
</SCRIPT>
</HEAD>
<BODY>
<button onclick="call C:\Users\user1\Documents\bat1.bat";closeHTA(1);>Bat1</button>
<button onclick="call C:\Users\user1\Documents\bat2.bat;closeHTA(2);">Bat2</button>
<button onclick="call C:\Users\user1\Documents\bat3.bat;closeHTA(3);">Bat3</button>
</BODY>
</HTML>
by I'm facing couple of problems:
- I get an error in line
<button onclick="call C:\Users\user1\Documents\bat1.bat";closeHTA(1);>Bat1</button>
saying a semicolon is expected as shown below, I'm not sure if this is the correct way to call a batchfile in this part? - How I can have a textbox so I can enter a parameter and pass it to one of the batch files?
- The GUI and cmd are not anchored so if I closed the cmd the GUI of the buttons still exists and doesn't close as shown below: