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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Windows Scripting to Print HTML File

Status
Not open for further replies.

snowyej

Technical User
Nov 26, 2001
69
0
0
US
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 :)
 
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.
[tt]
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
[/tt]
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
 
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
 
>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.
[tt]
surl="fixedupdatepage.htm" 'your input

dim bpttd_ready, istatus
set oie=wscript.createobject("internetexplorer.application","ie_")
[red]do while[/red] 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
[red]do while[/red] 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
[/tt]
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top