Solved

HTA Application Name not showing up in Task Manager

Posted on 2011-03-25
3
1,411 Views
Last Modified: 2012-05-11
I have an HTA application that I have the HTA tag set with the Application name.  Refering to Microsofts page (http://technet.microsoft.com/en-us/library/ee692768.aspx) the Application name tag will be the name that is displayed in the Task Manager.  For some reason this is not displaying in any task manger I run on Windows XP SP 3 machines.  I need this to display as an application in task manager because I have code in the HTA which actives the window:
set wshell=createobject("wscript.shell")
wshell.appActivate("MyHTA")

Any ideas on why this dose not display?

<html>
<head>
<title>HTA App</title>

<HTA:APPLICATION
     APPLICATIONNAME="MyHTA"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>

Open in new window

0
Comment
Question by:BKRsupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:Dhiraj Mutha
ID: 35220045
Try this and let me know what happens
<html>
<head>
<title>HTA App</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Admin Login"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     
>

<body bgcolor=black>

Open in new window

0
 
LVL 13

Accepted Solution

by:
Daz_1234 earned 500 total points
ID: 35226752
If you are using:

wshell.appActivate("MyHTA")

... Then it won't work because the title of your application is here:

<title>HTA App</title>

... so the correct line would be something like:

wshell.appActivate document.Title

But I've found in my testing that for some reason I don't completely understand, the AppActivate method only seems to work once during a running HTA.

The code snippet below demonstrates one method I got to make the HTA come to the foreground over and over again,

Basically it generates a VBscript and, works out the PID of itself and passes it to the generated VBScript which does the AppActivate independently.

The timers just mean that every 5 seconds it calls the sub which makes the HTA come to the foreground.

Hope this Helps,
Daz.
<html>
<head>
<title>HTA App</title>

<HTA:APPLICATION
     APPLICATIONNAME="MyHTA"
     ID="oHTA"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>

<script Language = "VBScript">
    Dim idTimer


    Sub Window_Onload
        idTimer = window.setTimeout("BringToFront()", 5000)
    End Sub

    Sub BringToFront()
        window.ClearTimeout(idTimer)
        MeFocus()
        idTimer = window.setTimeout("BringToFront()", 5000)
        Set wshShell = Nothing
    End Sub

    Sub MeFocus()
        Dim fso, ts, wshShell, sTempScript, objWMIService, colProcesses, objProcess, iPid, sCmdLine
        Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
        Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name='mshta.exe'")
        iPid = 0
        For Each objProcess in colProcesses
            If InStr(1, objProcess.CommandLine, oHTA.CommandLine, 1) <> 0 Then iPid = objProcess.ProcessID
        Next
        If iPid = 0 Then
            MsgBox "Unable to work out the PID of this HTA!" : Exit Sub
        End If
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set wshShell = CreateObject("WScript.Shell")
        sTempScript = wshShell.ExpandEnvironmentStrings("%temp%\MeFocus.vbs")
        If Not fso.FileExists(sTempScript) Then
            Set ts = fso.OpenTextFile(sTempScript, 2, True)
            ts.WriteLine "Set wshShell = CreateObject(""WScript.Shell"")"
            ts.WriteLine "wshShell.AppActivate WScript.Arguments(0)"
            ts.Close
        End If
        wshShell.Run "WScript.exe """ & sTempScript & """ " & iPid, 0, True
    End Sub

</script>

</head>

<body>

<p> Test HTA </p>


</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:BKRsupport
ID: 35231793
This is a bit more of a complicated solution but it works.  According to the Microsoft page the ApplicationName is what should be listed in the Task Manager Application list, not title.  However neither is listed in the task manager which is why your solution for finding the Process ID works and activating that will have to work.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question