×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to use Windows Scripting to Print HTML File

How to use Windows Scripting to Print HTML File

How to use Windows Scripting to Print HTML File

(OP)
Not sure if this is the right forum or not...but hopefully someone can help.  :)

I have an html file that is autogenerated every hour.  I want to create a scheduled task that will run a script (vbscript or batch file) that will print that html file to a network printer every hour.  I've searched all over but can't seem to find the answer.  Does anyone know of a way to do this?

Thanks in advance!!

Elizabeth :)

RE: How to use Windows Scripting to Print HTML File

The simplest approach is to use at to schedule to run a simple script to print the page every hour (?). The print script can be like this.

surl="fixedupdatepage.htm"    'your input

dim bpttd_ready, istatus
set oie=wscript.createobject("internetexplorer.application","ie_")
for oie.readystate<>4 : wscript.sleep 50 : loop
on error resume next
istatus=oie.querystatuswb(6)
if err.number<>0 then
    wscript.echo "Cannot find the printer. Operation aborted."
    oie.quit
    set oie=nothing
    wscript.quit err.number
end if
on error goto 0
oie.navigate surl
for oie.readystate<>4 : wscript.sleep 50 : loop
bpttd_ready=false
oie.execwb 6,2
do while not bpttd_ready : wscript.sleep 50 : loop
oie.quit
set oie=nothing
wscript.quit

sub ie_PrintTemplateTeardown(pDisp)
    bpttd_ready=true    'global bpttd_ready; no dim here
end sub

A more sophisticated approach is to monitor the creation/modification of the page and print it with an event consumer. I think you should not complicate the matter unnecessarily. At should work good enough. If you want to wscript.echo message, you should host the script with cscript. You don't want user-interactive for scheduled job, do you?! I do not.

- tsuji

RE: How to use Windows Scripting to Print HTML File

(OP)
Thanks for the response!  I am getting this error when trying to run the script:

Line: 5
Char: 19
Error: Invalid 'for' loop control variable
Code: 800A0410

Seems to not like the '<>' for some reason?  Any suggestions?

Thanks!
Elizabeth

RE: How to use Windows Scripting to Print HTML File

>Error: Invalid 'for' loop control variable
You're right. All come from my realtime brain-coding. It sure is do while instead of for everywhere at similar place.

Here is a re-list.

surl="fixedupdatepage.htm"    'your input

dim bpttd_ready, istatus
set oie=wscript.createobject("internetexplorer.application","ie_")
do while oie.readystate<>4 : wscript.sleep 50 : loop
on error resume next
istatus=oie.querystatuswb(6)
if err.number<>0 then
    wscript.echo "Cannot find the printer. Operation aborted."
    oie.quit
    set oie=nothing
    wscript.quit err.number
end if
on error goto 0
oie.navigate surl
do while oie.readystate<>4 : wscript.sleep 50 : loop
bpttd_ready=false
oie.execwb 6,2
do while not bpttd_ready : wscript.sleep 50 : loop
oie.quit
set oie=nothing
wscript.quit

sub ie_PrintTemplateTeardown(pDisp)
    bpttd_ready=true    'global bpttd_ready; no dim here
end sub

- tsuji

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close