Assistance needed with HTA and VB scrpting project

Posted on 2009-04-16
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="" height="90%" width="100%"></iframe> </p>



Open in new window

Question by:mvdave
    LVL 9

    Expert Comment

    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

    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

    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.

    LVL 65

    Accepted Solution

    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 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

    Thanks Rob. That worked. Sorry for not getting back to you sooner. Much appreciated.
    LVL 3

    Expert Comment

    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
    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)

    734 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

    20 Experts available now in Live!

    Get 1:1 Help Now