Activating a BAT file from a HTA

E

Edmund

How can I execute a '.bat' file from the below HTM?
________________________________________________
<HTML>
<HEAD>
<TITLE>Test Button Events</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
...(How?)...cmd.exe "C:\Test.bat"...(How?)...
</SCRIPT>
</FORM>
</BODY>
</HTML>
________________________________________________
Thanks a million!
 
E

Edmund

I'm just trying to lauch the bat file when user click the button they see in
Internet Explorer.

My "Test.bat" file contains only te below 2 lines:
__________________________________________
prompt off
"C:\Test\LaunchSub.vbs" "Apple" "Banana"
__________________________________________

Fyi, this question is actually related to my earlier post entitled "Passing
argument from cmd.exe to Excel VBA".

I'm trying to achieve this:
In IE, when user press the button, it will trigger 'Test.bat' to launch.
This will inturn trigger 2 arguments be passed from "C:\Test\LaunchSub.vbs"
"Apple" "Banana" to Excel VBA.

Thanks a million!
 
U

urkec

Edmund said:
I'm just trying to lauch the bat file when user click the button they see in
Internet Explorer.

My "Test.bat" file contains only te below 2 lines:
__________________________________________
prompt off
"C:\Test\LaunchSub.vbs" "Apple" "Banana"
__________________________________________

Fyi, this question is actually related to my earlier post entitled "Passing
argument from cmd.exe to Excel VBA".

I'm trying to achieve this:
In IE, when user press the button, it will trigger 'Test.bat' to launch.
This will inturn trigger 2 arguments be passed from "C:\Test\LaunchSub.vbs"
"Apple" "Banana" to Excel VBA.

Thanks a million!


This will work in HTAs, but in a HTML page you may receive a security warning:

<HTML>
<HEAD>
<TITLE>Test Button Events</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd.exe 'C:\Test.bat'"
</SCRIPT>
</FORM>
</BODY>
</HTML>
 
E

Edmund

cmd.exe did launch but seems the Test.bat file did not run. I'm unfamiliar
with commands related to cmd.exe & is clueless in troubleshooting your
suggestion of adding .....

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd.exe 'C:\Test.bat'"

If there's any URL to read, pls direct me there.

Thanks again for any help.
 
U

urkec

Edmund said:
cmd.exe did launch but seems the Test.bat file did not run. I'm unfamiliar
with commands related to cmd.exe & is clueless in troubleshooting your
suggestion of adding .....

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd.exe 'C:\Test.bat'"

If there's any URL to read, pls direct me there.

Thanks again for any help.


You could add /k to keep Command Prompt open after executing Test.bat, so
you can see if there are any error messages.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /k C:\Test.bat"

For help on commands type HELP or HELP command-name (like HELP CMD) in
Command Prompt.
 
D

Dennis_Reinhardt

You may also want to want to look at a commercial product: HtmlApp
Studio Professional (http://www.htmlapp.com). I believe the Wsh
solution always shows the batch file. HtmlApp Studio Professional
allows you to make the batch file either visible or invisible. There
are other features you may find of use beyond just solving your
immediate problem.

After download, look in the Help file under Help >> Browse User Manualshortcut http://127.0.0.1:31993/userref.py?format=topic&match=9.5.6
(when Html App Studio is running) for documentation.

My name, email, and phone number are shown on the contact us page so
don't hesitate to contact me if you run into any difficulties.

Regards, Dennis
DAIR Computer Systems
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top