cmd - Input form for batch with HTA -
how can make simple input form in hta , read batch in simple variable, , button proceed. don't know other way make decent gui batch file. this
any appreciated.
in short, need is
get reference standard output stream inside
.hta
file , write output content of fieldexecute
.hta
batch file usingfor /f
command process data sent standard output.
the "problem" need explicitly call mshta.exe
executable full path .hta
file.
serialnumber.hta
<html> <head> <hta:application id = "serialhta" applicationname = "serialhta" version = "0.1" navigable = "yes" showintaskbar = "yes" singleinstance = "yes" windowstate = "normal" border = "normal" borderstyle = "normal" innerborder = "no" caption = "yes" minimizebutton = "yes" maximizebutton = "yes" sysmenu = "yes" scroll = "yes" scrollflat = "yes" contextmenu = "yes" selection = "yes" /> <title>input serial number</title> <script language="javascript"> function closehta(sendoutput){ if (sendoutput){ (new activexobject('scripting.filesystemobject')) .getstandardstream(1) .writeline( document.getelementbyid('serialnumber').value ); }; window.close(); } </script> </head> <body> <label for="serialnumber">serial:</label> <input type="text" id="serialnumber"> <br> <button onclick="closehta(true);">ok</button> <button onclick="closehta();">cancel</button> </body> </html>
serialnumber.cmd
@echo off setlocal enableextensions disabledelayedexpansion set "serialnumber=" /f "delims=" %%a in ('mshta.exe "%~dp0\serialnumber.hta"') set "serialnumber=%%a" if defined serialnumber ( echo serial number: %serialnumber% ) else ( echo no serial number provided )
Comments
Post a Comment