PC Review


Reply
Thread Tools Rate Thread

Activating a BAT file from a HTA

 
 
Edmund
Guest
Posts: n/a
 
      4th May 2008
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!
--
Edmund
(Using Excel XP)
 
Reply With Quote
 
 
 
 
Edmund
Guest
Posts: n/a
 
      4th May 2008
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!

--
Edmund
(Using Excel XP)

 
Reply With Quote
 
urkec
Guest
Posts: n/a
 
      4th May 2008
"Edmund" wrote:

> 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!
>
> --
> Edmund
> (Using Excel XP)
>



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>


--
urkec
 
Reply With Quote
 
Edmund
Guest
Posts: n/a
 
      4th May 2008
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.

--
Edmund
(Using Excel XP)
 
Reply With Quote
 
urkec
Guest
Posts: n/a
 
      4th May 2008
"Edmund" wrote:

> 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.
>
> --
> Edmund
> (Using Excel XP)



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.

--
urkec
 
Reply With Quote
 
Dennis_Reinhardt
Guest
Posts: n/a
 
      4th May 2008
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 Manual
>> Server Run time Interface >> Run External Programs or use the

shortcut http://127.0.0.1:31993/userref.py?fo...ic&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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem, need to keep reinstalling/activating everything, boot.ini file vanished! Steelercaz Windows XP General 2 5th Aug 2009 02:40 PM
Activating an open file with a variable name Andyjim Microsoft Excel Programming 4 21st Dec 2007 06:32 PM
Activating cell in a file Roger Microsoft Excel Misc 2 7th Jul 2005 10:52 PM
Activating/De-activating buttons =?Utf-8?B?TmFzaA==?= Microsoft Excel Programming 4 22nd Jun 2005 07:24 AM
opening or activating another workbook file Paul James Microsoft Excel Programming 8 2nd Jan 2004 12:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.