I'm creating this HTA app with JScript that writes a BAT file and opens it in cmd
afterwards.
If I manually open the created BAT file from windows it works like it should.
When I open it through my HTA, the file opens but only outputs Echo and pause.
Please keep in mind, I'm very very new at programming.
Here is the JScript.
// Write the Bat file
// When run from HTA all I get is the "Echo Done" and "Pause"
// When I run from Windows without HTA, all of it works.
function writeBat() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:/test/test.bat");
s.WriteLine('@echo off');
s.WriteLine('set output=C:/test/new/');
s.WriteLine('FOR %%a in (*.mkv) DO ("C:/Program Files/MKVToolNix/mkvmerge.exe" -o "%output%%%~na.mkv" "%%a")');
s.WriteLine('echo Done.');
s.WriteLine('pause');
s.Close(); }
// Run the Bat file.
function runBat() {
var MyObject = new ActiveXObject("wscript.shell");
MyObject.Run("C:/test/test.bat"); }
Here is the Batch file.
@echo off
set output=C:/test/new/
FOR %%a in (*.mkv) DO ( "C:/Program Files/MKVToolNix/mkvmerge.exe" -o "%output%%%~na.mkv" "%%a")
echo Done.
pause
And the HTML
<form>
<input type="button" value="Write Bat" onClick="writeBat()">
<input type="button" value="Run Bat" onClick="runBat()">
</form>