Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HTA Application Name not showing up in Task Manager

Posted on 2011-03-25
3
Medium Priority
?
1,499 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
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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)
Suggested Courses

810 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