I am trying to keep the .hta file inside the same folder as an .exe that I wish to run. I understand there are at least 2 ways to start this app from a .hta file.
I would prefer it if the code can be complete inside one file, instead of send the user input variables to a batch file, but whatever works best.
- the .hta must work out which working folder (SourceDir) it is operating in and use that as part of a command variable for the .exe
- the user will select, from a drop down list, a few options. Whatever is selected that will be used as part of a command variable for the .exe (in addition to the above) 2a. the user can then choose to enter a value in a text box which will add an extra variable to the .exe
- the user will then have 2 buttons to click on to complete the form. Whatever is chosen dictates the path for the final part of the command line output.
current batch file for path 1:
@echo off
cd SourceDir
app.exe -v --log-file testH.txt -H -L "SourceDir\123\x.dll"
"SourceDir\456\abc.rar"
current batch file for path 2:
@echo off
cd SourceDir
app.exe -v --log-file testC.txt -C usertext -L "SourceDir\123\x.dll"
"SourceDir\456\abc.rar"
I have a basic code that doesnt quite work:
<SCRIPT LANGUAGE="VBScript">
Sub Hosting
Set Shell = CreateObject("WScript.Shell")
Shell.run "app.exe -v --log-file testH.txt -H -L "&
SourceDir.Value & "123\x.dll" & SourceDir.Value & "456\abc.rar"
End Sub
</SCRIPT>
How do I get the form fields and sourcedir data to work on this exe ? would it be easier to transfer the variarbles to a batchfile and edit accordingly?
small section part:
<html>
<head>
<title>Test</title>
<HTA:APPLICATION
ID="objHTA_Info"
APPLICATIONNAME="HTA_Info"
SINGLEINSTANCE="yes"
>
<script language="VBScript">
FullName = replace(objHTA_Info.commandLine,chr(34),"")
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir=replace(FullName,FileName,"")
Sub Window_onLoad
html = "<TABLE><TR><TD><b>Directory of app.exe </b></TD></TR><TR><TD>" & SourceDir & "</TD></TR></TABLE>"
BLAH.InnerHTML = html
End Sub
Sub RunProgram
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "app.exe -L " & SourceDir & "123\x.dll" & SourceDir & "456\abc.rar"
End Sub
</script>
</head>
<body>
<button onclick="RunProgram">Run app.exe</button>
<SPAN ID=BLAH></SPAN>
</body>
</html>
The first part of the script works fine and displays the correct working directory path. Clicking the button opens the app but crashes due to the errors of the parameters.
Without the parameters it runs fine:
Sub RunProgram
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "app.exe"
End Sub
I need the parameters! Any help gratefully appreciated!