Or......perhaps that line 37 is in your HTA, and the HTA is trying to close while it is still executing some code?
Main Topics
Browse All TopicsWell....it looks like it's my turn to ask a question - WooHoo! :o)
I am developing a method for our imaging that PXE boots to WinPE, launches a VBScript to run wpeinit, map a drive and call up an HTA where you can select an image to apply to the workstation. All this works fine, the HTA runs, my choices are captured via radio buttons and checkboxes and Ghost32 is run with the proper commandline switches.
The issue I'm having is when the Ghost client finishes, it closes then the HTA closes - which *should* return control to the originating VBScript to execute the next line in the script. However....the calling script throws an error:
Start.vbs (37, 1) (null): The operation was canceled by the user.
Now, I've started the HTA using several methods - objShell.Run "x:\windows\system32\mshta
I have other things in the calling script that execute, wait and then continue after completion just fine. It's only this return from the HTA that has greatly reduced the existence of hair on my head.
Is there any method at all I can leverage short of including the VBScript I need to launch after the HTA closes within the HTA itself? I don't like that last idea given how I have to maintain things.
Code gurus, I'm all ears ('cause I have no more hair)!! LOL.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Rob, thanks for flying Netman!
Line 37 is from the calling script and is the next line after:
objShell.Run "x:\windows\system32\mshta
objShell.Run "cscript.exe s:\scripts\ai-ph1.vbs",2,T
I'll have to post the code tomorrow - it's at the office, but there is something in the way the HTA or mshta.exe process ends that kills the calling script (start.vbs). When an external process is spawned from within a VBScript, does it become a child process or a process of it's own? I'm wondering if it runs under the PID of the cscript process and when I kill mshta it kills the whole PID. Does that make any sense?
Hmmm, I can't see why that would fail.....
To answer your PID question.....I used Process Explorer to look at the tree when I ran the code segments below....
The first script will spawn separate processes for any external programs run, which do not seem to be dependant on the parent process running. If I kill the highest process in the tree, the HTA stays running.
Anyway, I can run the below three code files without error....
So I'm not sure just yet why you'd have an issue......
Regards,
Rob.
Interesting....
Let me fill in a few holes in my original post - perhaps there is a difference that is relevant to you.
I startup a new workstation and hit F12 to PXE boot.
It boots up from the network into WinPE - all the modules are loaded in PE (WMI, Scripting, XML and HTA).
Startnet.cmd loads, by default, as the shell - so I'm using it.
Starnet runs one line - cscript x:\Windows\start.vbs (which is embedded into the PE wim).
Start.vbs launches WPEINIT.exe (waits), maps a network drive (waits), runs the HTA from the mapped drive (waits).
The HTA parses the mapped drive (in a certain folder) and dynamically creates buttons based on the top level folders in this location.
When a button is pressed, it parses the contents of that folder and dynamically creates radio buttons for each .gho image it finds.
When one of those radio buttons is selected a new button is created to start the imaging process using Ghost (embedded in the wim) and builds the commandline from the radio choices you make in the HTA.
Ghost launches and attaches to the Ghostcast server session name that is built above.
The image is brought down to the machine and Ghost exits.
The HTA exits.
The next line of code in the Start.vbs is supposed to execute, but the error in the original post is presented in the CMD window that was originally launched by Startnet.cmd.
So, the process is a bit weird but goes something like this:
Startnet.cmd > run Start.vbs > Run Wpeinit.exe (wait) > Map Drive > Run HTA (wait) >> HTA runs Ghost32.exe (which itself opens a CMD window to run itself - kinda different...) > Ghost32 exits > CMD window that launched Ghost exits > HTA exits > apparently the Start.vbs exits due to an error > error is presented in CMD shell started by Startnet.cmd.
I wonder if running the HTA from the network is influencing the problem? Perhaps WinPE Scripting isn't up to the task of running it on a real OS? Dunno....
As you can tell, I don't write Apps for a living. I'll script for Administration, but do not normally get invloved in anything that resembles an App. This is my first shot at creating an HTA based on one I found on the Internet and modifying it to do what I need it to. For the most part, each component of this process works fine it's only when I attempt to run it all together sequentially that I'm running into unforseen problems.
Thanks for your time so far Rob.
Hmmmm.....OK, so first off I'm wondering if CScript.exe actually executes properly in WinPE.....
Try my files out, using this as your HTA.
See if that gets to the cscript.exe OK....
If not, then you may have to use WScript.exe (or whatever happens to run a VBS by default, maybe a different implementation on WinPE).
Regards,
Rob.
OK, I'm game. I'll test this out tomorrow when I have a PE environment to work from.
If you send me an email at my alias here at gmail then I'll send you the scripts I'm using tomorrow - I don't want some of the info in them public (and scrubbing them would defeat the purpose if you need them to work).
I'll also report back with the results of this test.
Again, thanks Rob!
OK. I don't have a WinPE environment that I could test in, so let's try to work without sending whole scripts....just relevant parts around problem areas are fine.
In the test code I gave above, we're pretty much emulating what you've got, just shortened it a bit, so hopefully we can get some results out of it....
Rob.
OMG........
You're not going to believe the ridiculously noob error I made in my script....
I tested my solution with your simple HTA - same results as I was getting previously.
Here is the line that was giving me the original error (objShell defined earlier in the script).
objShell.Run "S:\Scripts\AI-Ph1.vbs",2,
After looking at this issue for hours, a good night sleep is all I needed to spot the problem as soon as your HTA did the same thing.
The line should have been:
objShell.Run "cscript S:\Scripts\AI-Ph1.vbs",2,T
This is a perfect example of why you should take a break after long hours of scripting. You look at the same error over and over but it never strikes you as being incorrect.
Rob - I have to thank you for your patience and making me THINK. I hope I can get your assistance for future problems in VBScripting.
Now to start looking at regrowing my hair!
Cheers,
NM
>> The kicker here too is that I typed that problem line perfectly correct when I was posting it here in my first reply to you. Unreal....
LOL! Yeah, I noticed that! Ah well, at least you've found the issue! Well done!
Yesterday I was writing a HTA to install a program and update some shortcuts in a folder. It was throwing an error every time I ran, even though I knew the shortcuts were there. I had this
For Each objFile In objFSO.GetFolder(strFolder
which threw the error, and it me ages to remember that I needed to add .Files to the end!
It's those "not quite eyntax" errors, but just omissions that make the most frustrating errors.
Anyway, sure, throw me a line if you need VBS / HTA help.....
Thanks for the grade, and the comments....
Regards,
Rob.
Business Accounts
Answer for Membership
by: RobSampsonPosted on 2008-10-16 at 13:36:49ID: 22735500
Hi netman,
.exe s:\scripts\menu.hta",3,Tru e
e
,True
Is this line 37?
objShell.Run "x:\windows\system32\mshta
it seems a strange error to have from that line.....
You can shorten that to just
objShell.Run "mshta.exe s:\scripts\menu.hta",3,Tru
because mshta.exe is a system file.
Also, if your HTA path happens to have spaces, use
objShell.Run "mshta.exe ""s:\scripts\menu.hta""",3
Regards,
Rob.