Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with HTA

Status
Not open for further replies.

MikeWarner

Programmer
Oct 7, 2004
7
US
I need to launch an HTA, have the user input data of some kind, return the data to the calling script, and close the opened HTA window.

I can get the HTA to launch, but from there I am having the difficulties. Below is my calling script and a copy of somebody else's (not sure whos) HTA that I am using just to test out how I will be doing this.

Calling Script
-------------------
Code:
Set oShell = CreateObject("WScript.Shell")
MsgBox "Lets see what is happening."
oShell.exec "mshta c:\testout.hta"
HTA
----------------------------
Code:
<HTML>
    <HEAD>
    <HTA:APPLICATION ID="oFinder"
     APPLICATIONNAME="Finder"
     BORDER="thin"
     BORDERSTYLE="normal"
     CAPTION="yes"
     ICON=""
     MAXIMIZEBUTTON="yes"
     MINIMIZEBUTTON="yes"
     SHOWINTASKBAR="yes"
     SINGLEINSTANCE="no"
     SYSMENU="yes"
     VERSION="1.00"
     WINDOWSTATE="maximize"/>

    <TITLE></TITLE>
    <script language=vbscript>
    
        Dim strReply
        strReply = "Nothing"
    
        Sub btnReply_onclick
	    'i believe here is where I want to return the  data and exit the hta
        End Sub
    
        Sub rdoOne_onclick
            rdoOne.status = True
            rdoTwo.status = False
            rdoThree.status = False
            strReply = "ONE"
        End Sub
    
        Sub rdoTwo_onclick
            rdoOne.status = False
            rdoTwo.status = True
            rdoThree.status = False
            strReply = "TWO"
        End Sub
    
        Sub rdoThree_onclick
            rdoOne.status = False
            rdoTwo.status = False
            rdoThree.status = True
            strReply = "THREE"
        End Sub
    
    </script>
    </HEAD>
    <BODY>
        <p>
         <input 
        id=rdoOne type=radio>&nbsp;One</p>
        <p>
         <input id=rdoTwo type=radio>&nbsp;Two</p>
        <p>
         <input id=rdoThree type=radio>&nbsp;Three</p>
        <p>
         <input id=btnReply type=button value=Reply></p>
    </BODY>
</HTML>

Any help will be greatly appreciated.
 
Normally one uses the Exec method to invoke command-line programs as a separate process. This gives you the ability to communicate with the new process via it's standard I/O streams.

On many systems you can't Exec mshta and get results. You'll find the task sitting there in Task Manager, but the HTA window will never open. This may be related to security patches installed.

Even if it does run your HTA properly though, an HTA can't get to the stdio streams to communicate back to your WSH script. You'd have to do something else like communicate via disk files or MSMQ queues or Winsock or something. The two processes end up being pretty much decoupled in effect.

In most cases where an HTA makes sense, it makes sense for all of the script logic to be in the HTA itself. If you need both types of desktop scripting (WSH and HTA) you are usually going to be better off having the HTA be the "amin" or "parent" process. Any WSH scripts can talk back and forth to the parent HTA via their stdio streams - it just doesn't go both ways.

The HTA can be parent, but not child.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top