Assistance needed with HTA and VB scrpting project

Posted on 2009-04-16
Medium Priority
Last Modified: 2012-05-06
Hello Experts, I hope sombody can point me in the right direction.

A client has asked me to develop an HTA that basically interrupts the login process and runs a trusted HTA that forces teh user to login to a timesheet application. It is launched immediately after login to thier Windows Xp workstations that are connected to a 2003 ACtive Directory server.

The application launches before the main Windows executable launches, and opens an i-frame that points to one of thier servers and opens thier timesheet recording application, hosted on IIS. All that works OK and runs as expected.(in the attached code sample I have replaced the timesheet URL with Google's home page so it works if you save and rename as an HTA

To get it to launch automatically, I edited registry keys as follows:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell  (removed explorer.exe)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit (set to: C:\WINDOWS\system32\userinit.exe,"C:\Program Files\Internet Explorer\iexplore.exe" "C:\Program Files\RazorTime\RazorTime.hta")

The problem occurs when the user clicks the 'close' button. The app' closes just fine and calls Windows Explorer, but it doesn't launch the whole Windows environment properly. It just calls a Windows explorer session. No desktop icons, no taskbar, no nuffin'!

I'm hoping somebody can examine the attached code sample and give me a simple fix, or tell me if I'm going about this completely the wrong way , especially with regard tot he VB script. Bit of noob on that.. Is there some other way to call Explorer so it basically retunrs teh user to 'normal service"...

Thanks in advance for any assistance
Dave, Sydney AU

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script Language = VBScript>
	Sub Exit_HTA
		Set objShell = CreateObject("WScript.Shell")
		objShell.Run "explorer.exe"
	End Sub
<body bgcolor="rgb(0,0,0)" border="1">
<img style="width: 134px; height: 70px;" alt="" src="%5Crazorlogo.png">;
<button style="width:65;height:35" onClick="history.go(-1)"><b>Back</b></button>
<button style="width:65;height:35" onClick="history.go(1)"><b>Forward</b></button>
<button style="width:65;height:35" onClick="window.location.reload()"><b>Reload</b></button>
<button style="width:65;height:35" onClick="vbs:Exit_HTA"><b>Exit</b></button>
<iframe id="frmClient" trusted="yes" src="http://www.google.com.au" height="90%" width="100%"></iframe> </p>

Open in new window

Question by:mvdave

Expert Comment

ID: 24158966
Couldn't you let the explorer.exe load as normal and still display the HTA automatically?  Maybe set the HTA to maximized and disable the "X" close button, minimize and restore buttons, and even disable the close button until they have performed an action on the form?  That way they would have to do whatever it is your wanting them to do before accessing their desktop but the desktop still loads normally.
LVL 65

Expert Comment

ID: 24163176
Hi, perhaps try putting the HTA path in the RunOnce key instead......that will load before Explorer loads, and Explorer will only load after that closes.  Then a login script could put the entry back into RunOnces (because they automatically get deleted).



Author Comment

ID: 24164108
Thanks gents for your input.

@dan_neal: Yep, it does all that already. the 'sysmenu=no' entry in the HTA definition turns off the min/restore and close buttons. The ifrae window passes control to another app' so I've no way of knowing whether they've actually done anything or not.... This whole exercise is to give end users the illusion that they "have to' complete their time sheets. In actual fact, there's no real difference in loading explorer in the background and maximising the HTA to full screen. Either way, if they click the Exit button, they're closing out and will (one way of another) find themselves at thier regular desktop. I was just hoping I could complete the illusion somewhat. Thank you anyway.

@RobSampson: Again thanks for your input. When I was initially searching around VB Script zones on EE, I'd seen a lot of your answers and liked teh quality of your answers. So thanks! I've been doing my testing on a VM which is easy to roll back if things go pear-shaped. I had considered doing the  whole thing in a login-script, but I'm concerned that if I make what is effectively a destructive RegEdit  and subsequently, the login script doesn't fire to tidy-up (for whatever reason..) , then I'm stuck with a machine that needs a registry restore and an unhappy user calling me in to clean-up manually.

Thanks guys.

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.

LVL 65

Accepted Solution

RobSampson earned 750 total points
ID: 24164488
Hi there, I'm glad you like my answers....some are pretty good....others a bit rushed....which is bad I know, but it's all I can offer sometimes :-)

Anyway, back to your question...
>> but I'm concerned that if I make what is effectively a destructive RegEdit....

I'm not sure I understand.....The RunOnce key is documented by Microsoft as a key that allows software to be run before the Shell loads.  It then goes on to say that these entries always delete themselves after running.  You may have seen something like SpyBot, which can ask you if you want to run it on the next reboot...well, that uses the same thing....it places the SpyBot command in the RunOnce key, so that it runs once and once only.  So what I'm saying here, is that if your HTA runs from a RunOnce entry, the shell won't load until that exits, but you do need to re-add the RunOnce entry by some other means...perhaps a StartUp and Logoff Script combination....

It should work....but of course, you can test it...see here for more info on the RunOnce keys...



Author Closing Comment

ID: 31570945
Thanks Rob. That worked. Sorry for not getting back to you sooner. Much appreciated.

Expert Comment

ID: 25621494
This isn't the most elegant solution, but I've used it for kiosk style implementations and I know it works.  Try using the command line "taskkill" utility.  So, here's how it works...

1)  User logs in/authenticates
2)  Windows explorer.exe loads normally
3)  Login script kills explorer.exe using taskkill
4)  Login script calls the hta
5)  User clocks in, closes window
6)  Close button calls "explorer.exe"

If you do this, explorer.exe should open up as planned.

Info on the taskkill utility:


Good luck!

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

862 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