• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1480
  • Last Modified:

Assistance needed with HTA and VB scrpting project

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">
<html>
<head>
  <title>RazorTime</title>
 
 
  <hta:APPLICATION 
id="oApp" 
applicationname="Timesheets" 
border="thin" 
caption="yes" 
icon="app.ico" 
showintaskbar="yes" 
singleinstance="yes" 
sysmenu="no" 
windowstate="maximize" 
scroll="yes" 
scrollflat="yes" 
version="1.0" 
innerborder="yes" 
selection="yes" 
maximizebutton="yes" 
minimizebutton="yes" 
navigable="yes" 
contextmenu="yes" 
borderstyle="normal">&gt; 
</hta:APPLICATION>
 
<script Language = VBScript>
	Sub Exit_HTA
		Set objShell = CreateObject("WScript.Shell")
		objShell.Run "explorer.exe"
		Window.Close
	End Sub
</script>
 
</head>
 
 
<body>
<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>
<sp>
<button style="width:65;height:35" onClick="history.go(1)"><b>Forward</b></button>
<sp>
<button style="width:65;height:35" onClick="window.location.reload()"><b>Reload</b></button>
<sp>
<button style="width:65;height:35" onClick="vbs:Exit_HTA"><b>Exit</b></button>
 
<p>
<iframe id="frmClient" trusted="yes" src="http://www.google.com.au" height="90%" width="100%"></iframe> </p>
 
</body>
</html>

Open in new window

0
mvdave
Asked:
mvdave
1 Solution
 
dan_nealCommented:
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.
0
 
RobSampsonCommented:
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).

Regards,

Rob.
0
 
mvdaveAuthor Commented:
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.

dp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
RobSampsonCommented:
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...
http://support.microsoft.com/kb/137367
http://msdn.microsoft.com/en-us/library/aa376977(VS.85).aspx
http://technet.microsoft.com/en-us/library/dd346765.aspx

Regards,

Rob.
0
 
mvdaveAuthor Commented:
Thanks Rob. That worked. Sorry for not getting back to you sooner. Much appreciated.
0
 
englanddgCommented:
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:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskkill.mspx?mfr=true

Good luck!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now