Solved

HTA Application Name not showing up in Task Manager

Posted on 2011-03-25
3
1,366 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
3 Comments
 
LVL 14

Expert Comment

by:Dhiraj Mutha
Comment Utility
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 12

Accepted Solution

by:
Daz_1234 earned 500 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
css, html 6 29
FTP File permissions 1 27
Condidional <a href = ....> 1 22
How do i remove the outer scrollbar? 2 15
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now