使用PowerShell的IE浏览器保存网页 [英] Saving a web page from IE using Powershell

查看:321
本文介绍了使用PowerShell的IE浏览器保存网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Internet Explorer的自动化接口从PowerShell来支持的格式打开一个网页。我要救这个页面回磁盘中通过IE浏览器支持的格式之一。打开网页很简单:

I use the automation interface of Internet Explorer from Powershell to open a web page in a supported format. I want to save this page back to disk in one of the formats supported by IE. Opening the page is easy:

$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.Navigate("C:\MyFile.mht")

如何将其重新保存为另一种格式?

How do I save it back in another format?

我需要的,不提示用户,因为这个想法是通过多个文件运行自动运行该脚本中的解决方案。

I need a solution that does not prompt the user since the idea is to automate this in a script running through multiple files.

推荐答案

你要调用ExecWB用适当的args 的:

$ie.ExecWB(4,0,$null,[ref]$null)

4 PARAMS说明:

Explanation of the 4 params:

4 = OLECMDID_SAVEAS
0 = OLECMDEXECOPT_DODEFAULT (This can also be 2 = OLECMDEXECOPT_DONTPROMPTUSER to not prompt and just save)
$null = NULL (I think this can be a path to save to: separate folders with 2 slashes (\\))
[ref]$null = ref NULL :)

这篇关于使用PowerShell的IE浏览器保存网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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