使用 Powershell 从 IE 保存网页 [英] Saving a web page from IE using Powershell

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

问题描述

我使用来自 Powershell 的 Internet Explorer 自动化界面以支持的格式打开网页.我想以 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:

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

4个参数的解释:

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天全站免登陆