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 :)
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
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
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
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