Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling execution order in an HTA 2

Status
Not open for further replies.

PPettit

IS-IT--Management
Sep 13, 2003
511
US
I'm working on an HTA which includes a subroutine that executes two different commands (install a printer then load it's configuration file via "rundll32 printui.dll,PrintUIEntry..."). My problem is that the script tries to load the configuration file before the print driver is ready to accept it.

How can I force the "configuration" command to run only after the "install" command has completed what it needs to do? After searching around a bit, I discovered that I can't even use wscript.sleep for a temporary pause since it won't work in an HTA. I did find a few alternate ways to pause a script, but I'd prefer that the script be more precise and continue only after the previous command has finished.

Any ideas?

These are the commands that I'm running:
Code:
...
[i]install the printer[/i]
objShell.Run "rundll32 printui.dll,PrintUIEntry /if /b """ & printer.value & """ /f ""%windir%\inf\ntprint.inf"" /r ""IP_192.168.1.148"" /m ""HP LaserJet 2200 Series PCL 6"" /u"

[i]configure the printer[/i]
objShell.Run "rundll32 printui.dll,PrintUIEntry /Sr /n """ & printer.value & """ /a ""C:\Documents and Settings\Administrator\My Documents\Printer Settings\" & printer.value & ".dat"""
...
In case you wanted to know... printer.value is a variable containg the printer name.

If you want more info regarding printui.dll, just run this:
Code:
rundll32 printui.dll,PrintUIEntry /?
 
There's a parameter where if you set it to true it will wait until completed before proceeding. The 0 is the window state. You can change that if you want to see the window.
Code:
objShell.Run "rundll32 printui.dll,PrintUIEntry /if /b """ & printer.value & """ /f ""%windir%\inf\ntprint.inf"" /r ""IP_192.168.1.148"" /m ""HP LaserJet 2200 Series PCL 6"" /u",0,[b]True[/b]

Code:
objShell.Run "rundll32 printui.dll,PrintUIEntry /Sr /n """ & printer.value & """ /a ""C:\Documents and Settings\Administrator\My Documents\Printer Settings\" & printer.value & ".dat""",0,[b]True[/b]
 
you can call a vbs from hta. the vbs can contain wscript.sleep in it. that's how i do hta when i need to do "sleep".
 
here's the code executed from within hta:
Set wseExternal = _
wshShell.Exec("wscript.exe //NOLOGO HTAVBS.vbs")

the file, htavbs.vbs will contain "wscript.sleep".
 
That's an interesting solution as well, barny2006. I'll have to keep that in mind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top