我想使用PowerShell打印默认打印机的HTML文件。因此,可以说我有文本文件c:\ test.html:使用PowerShell自动打印HTML文件
<html>
<p> hello <b>world</b></p>
<html>
如何将test.html打印到默认打印机?
预先感谢您。
我想使用PowerShell打印默认打印机的HTML文件。因此,可以说我有文本文件c:\ test.html:使用PowerShell自动打印HTML文件
<html>
<p> hello <b>world</b></p>
<html>
如何将test.html打印到默认打印机?
预先感谢您。
get-content c:\test.html | out-printer
打印到默认打印机。
编辑:
,如果你需要打印呈现HTLM页面:
$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("c:\test.html")
$ie.ExecWB(6,2)
编辑点评后:
我可以在testprint.ps1文件中运行以下命令:
$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()
谢谢基督徒!几乎完美。我看到我一直在IE浏览器运行,我应该运行一个“关闭”命令?我试过$ ie.Quit()和$ ie.Close(),但没有运气。有任何想法吗? –
要将IE会话打开为$ ie,您必须调用$ ie.quit()。这不会关闭其他IE会话。你可以再次关闭所有其他IE会话吗? –
如果我放弃它不会打印。试过这个:“while($ ie.Busy){Start-Sleep -Milliseconds 400} $ ie.Quit()”但它不打印。 –
我假设你有兴趣打印呈现的输出,而不是HTML源代码。 – Filburt
完全Filburt。 –