使用PowerShell自动打印HTML文件 [英] print automatically html file with powershell

查看:471
本文介绍了使用PowerShell自动打印HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用powershell打印一个html文件到默认打印机。所以我们可以说我有文本c:\test.html和文本:

 < html> 
< p> hello< b>世界< / b>< / p>
< html>

如何将test.html打印到默认打印机?



预先感谢您。

解决方案

  get-content c:\test.html | out-printer 

打印到默认打印机。



<如果您需要打印呈现htlm页面:

  $ ie = new-object -comInternetExplorer.Application
$ ie.Navigate(c:\test.html)
$ ie.ExecWB(6,2)

在评论后编辑:



我可以在testprint.ps1文件:

  $ ie = new-object -comInternetExplorer.Application
$ ie.Navigate (c:\test.html)
while($ ie.busy){Start-Sleep -second 3}
$ ie.ExecWB(6,2)
while($ ie.busy){Start-Sleep -second 3}
$ ie.quit()


I want to print an html file to the default printer with powershell. So lets say I have the file c:\test.html with the text:

<html>
<p> hello <b>world</b></p>
<html>

How could I print test.html to the default printer?

Thank you in advance.

解决方案

get-content c:\test.html  | out-printer

Print to default printer.

Edit:

if you need print rendered htlm page:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("c:\test.html")
$ie.ExecWB(6,2)

Edit after comments:

I can run this in a testprint.ps1 file:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("c:\test.html")
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.ExecWB(6,2)
while ( $ie.busy ) { Start-Sleep -second 3 }
$ie.quit()

这篇关于使用PowerShell自动打印HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆