简体   繁体   English

通过Powershell / CMD安装IE11插件

[英]Installing addon for IE11 via Powershell/CMD

I am writing a Powershell script that sets up new computers at my workplace. 我正在编写一个Powershell脚本,该脚本可以在我的工作场所设置新计算机。 One of the things I am trying to do is install an Internet Explorer 11 addon that normally installs when a user first visits a particular website. 我要尝试做的一件事情是安装Internet Explorer 11插件,该插件通常在用户首次访问特定网站时安装。 Upon first visit, a popup window asks if they want to install it. 首次访问时,会出现一个弹出窗口,询问他们是否要安装它。

I located the file the website was downloading for the addon. 我找到了网站正在为插件下载的文件。 It was named "NAV1251.CAB". 它被命名为“ NAV1251.CAB”。

Inside of this .CAB file are two .dll files, two .tlb files, one .inf file, and one .ocx file. 在此.CAB文件中,有两个.dll文件,两个.tlb文件,一个.inf文件和一个.ocx文件。 I have tried the following things: 我尝试了以下操作:

  • Using regsvr32 to register the DLL files (got successful messages on both "DllRegisterServer in C:\\thefilename.dll succeeded") 使用regsvr32注册DLL文件(“在C:\\ thefilename.dll中的DllRegisterServer成功都获得了成功消息”)

  • Using regasm to register the type library (.TLB) files (got an error on both stating it could not load either file because it is not a valid .NET assembly) 使用regasm注册类型库(.TLB)文件(在两个文件上均提示错误,因为它不是有效的.NET程序集,因此无法加载这两个文件)

  • Installing the .INF (which fails when using the command pnputil -i -a "PathToFile", saying that the INF does not contain digital signature info) 安装.INF(使用pnputil -i -a“ PathToFile”命令失败,表示INF不包含数字签名信息)

  • Registering the OCX using regsvr32 (which, like the DLL files, gives me a successful message) 使用regsvr32注册OCX(与DLL文件一样,会给我成功的消息)

  • Tried installing the .CAB file itself using DISM, but am constantly given the error code 2 (Cannot find the file specified) regardless of where I put the file. 尝试使用DISM本身安装.CAB文件,但无论我将文件放在何处,始终会得到错误代码2(找不到指定的文件)。 I am 100% sure there are no typos in the command and that the file is where I am pointing to. 我100%确信命令中没有拼写错误,并且该文件是我指向的位置。 I also ensured to try every possible form of capitalization/no caps/quotes/no quotes to no avail. 我还确保尝试所有可能的大写形式/无大写/引号/无引号无济于事。 [Also tried using the Add-WindowsPackage cmdlet in Powershell and got the exact same error] [也尝试在Powershell中使用Add-WindowsPackage cmdlet并得到完全相同的错误]

I was thinking my best bet would be either installing the .INF or installing the .CAB itself. 我当时认为我最好的选择是安装.INF或安装.CAB本身。 But, funnily enough, the .CAB file itself IS digitally signed by the company, but the .INF file INSIDE of the .CAB is NOT. 但是,有趣的是,.CAB文件本身已由公司进行数字签名,但.CAB的.INF文件内部不是。

Outside of these efforts, I have also looked around in the registry to try and find the keys that relate to the addon. 除了这些努力之外,我还浏览了注册表,以查找与插件相关的密钥。 I found them and am able to import it into the script, but without the addon actually being installed, it is not working. 我找到了它们,并且能够将其导入到脚本中,但是如果没有实际安装插件,它将无法正常工作。 I can make it so a new addon appears in the list of IE's addons, but it will have no name or functionality. 我可以做到这样,一个新的插件会出现在IE插件的列表中,但是它没有名称或功能。 I am fairly sure I need to do something with the .CAB and the files within it, but I am stumped as to what at this point. 我相当确定我需要对.CAB及其中的文件进行某些处理,但是我对目前的情况感到困惑。

This must be done in Powershell or the Command Prompt. 这必须在Powershell或命令提示符中完成。 Please do not recommend using GPO as this is not the solution I am looking for. 请不要推荐使用GPO,因为这不是我想要的解决方案。

Any ideas? 有任何想法吗?

(If more info is needed, please ask and I can give you whatever you may need) (如果需要更多信息,请询问,我可以为您提供所需的任何信息)

EDIT: 编辑:

I got it working (check my own answer). 我让它正常工作(检查我自己的答案)。 However, I just now realized that it will only work for the user I run the script under. 但是,我刚刚意识到,它仅对我在其下运行脚本的用户有效。 For my implementation, it needs to be applied to the entire machine. 对于我的实现,它需要应用于整个机器。

I will continue to look into possible ways to make this happen, but if anyone wants to look at my answer and see if you know any possible ways to make this apply to the entire machine without needing to rerun the script on each user, that would be awesome! 我将继续研究使这种情况发生的可能方法,但是如果有人想看看我的回答,看看是否知道使此方法适用于整个计算机的任何可能方法,而无需在每个用户上重新运行脚本,那将会太棒了!

[I just realized that this is only going to work for the current user. [我只是意识到这仅适用于当前用户。 Now I need to somehow translate this to work on the entire machine...somehow. 现在,我需要以某种方式将其转换为可以在整个计算机上运行... :( ] :(]

I actually just got it working via Powershell. 我实际上只是通过Powershell使它工作的。 Needless to say, I jumped out of my chair and let out a little cheer when this worked. 不用说,当它起作用时,我跳出椅子,稍稍加油。 Quite frankly, I'm very surprised it did. 坦白说,我真的很惊讶。

For those wondering what I did, here is the exact Powershell script I used: 对于那些想知道我做了什么的人,这里是我使用的确切Powershell脚本:

Copy-Item -Path "E:\Script\Resources\NAV\NAV1251.ocx" -Destination "C:\Windows\SysWOW64"
Copy-Item -Path "E:\Script\Resources\NAV\NAV1251.ocx" -Destination "C:\Windows\System32"
Start-Process -FilePath "C:\Windows\System32\regsvr32.exe" 'C:\Windows\SysWOW64\NAV1251.ocx'
Start-Process -FilePath "C:\Windows\System32\regsvr32.exe" 'C:\Windows\System32\NAV1251.ocx'
reg import "E:\TheStuff.reg"

The registry file is where the magic happened here. 注册表文件是神奇的地方。

I used a free tool that allows you to take and compare snapshots of the registry. 我使用了免费工具,可让您获取和比较注册表快照。 I went to the webpage where the addon is needed, and the little popup came up asking if I want to install the addon. 我转到了需要插件的网页,然后弹出了一个小小的对话框,询问我是否要安装插件。 Before clicking install, I made a registry snapshot. 在单击安装之前,我制作了一个注册表快照。 Once that was made, I clicked install and immediately took another snapshot. 完成后,我单击“安装”,并立即拍摄了另一个快照。

Using the program, I was able to see all changes that were made to the registry. 使用该程序,我可以看到对注册表所做的所有更改。 I know the class ID of the addon, so I was looking for anything that contained that or pertained to Internet Explorer. 我知道插件的类ID,因此我正在寻找包含Internet Explorer或与Internet Explorer有关的任何内容。 There were a few different keys there. 那里有几个不同的键。 I added all of those keys to a .reg file named "TheStuff.reg". 我将所有这些键添加到名为“ TheStuff.reg”的.reg文件中。 I then threw together the rest of the script and figured it would be worth a try. 然后,我把其余的脚本放在一起,认为值得一试。

I went to a brand new PC, ran the script, and went to the webpage. 我去了一台全新的PC,运行了脚本,然后去了网页。 No install prompts. 没有安装提示。 The addon was installed, enabled, and allowed to run on the website all from the script. 该插件已通过脚本安装,启用并允许在网站上运行。 This is EXACTLY what I needed. 这正是我所需要的。

For anyone interested in the REG file contents (maybe you want to install an Internet Explorer addon yourself), this is how the file looks: 对于对REG文件内容感兴趣的任何人(也许您想自己安装Internet Explorer插件),这是该文件的外观:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]
"Zvpebfbsg.VagreargRkcybere.Qrsnhyg"=hex(3):00,00,00,00,0D,00,00,00,0D,00,\
00,00,12,67,08,00,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,\
BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,FF,FF,FF,FF,\
F0,80,22,24,6F,35,D4,01,00,00,00,00
"P:\Hfref\hfre\Qrfxgbc\ertvfgelpunatrfivrj-k64\ErtvfgelPunatrfIvrj.rkr"=hex(3):\
00,00,00,00,01,00,00,00,02,00,00,00,D0,7F,00,00,00,00,80,BF,00,00,80,BF,00,\
00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,80,BF,00,00,\
80,BF,00,00,80,BF,FF,FF,FF,FF,D0,19,64,32,6F,35,D4,01,00,00,00,00
"HRZR_PGYFRFFVBA"=hex(3):00,00,00,00,63,00,00,00,DD,00,00,00,4B,A4,63,00,13,\
00,00,00,3A,00,00,00,E8,FE,16,00,4D,00,69,00,63,00,72,00,6F,00,73,00,6F,00,\
66,00,74,00,2E,00,57,00,69,00,6E,00,64,00,6F,00,77,00,73,00,2E,00,45,00,78,\
00,70,00,6C,00,6F,00,72,00,65,00,72,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,13,00,00,00,3A,00,00,00,E8,FE,16,00,4D,00,69,00,63,00,72,\
00,6F,00,73,00,6F,00,66,00,74,00,2E,00,57,00,69,00,6E,00,64,00,6F,00,77,00,\
73,00,2E,00,45,00,78,00,70,00,6C,00,6F,00,72,00,65,00,72,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,13,00,00,00,3A,00,00,00,E8,FE,16,00,\
4D,00,69,00,63,00,72,00,6F,00,73,00,6F,00,66,00,74,00,2E,00,57,00,69,00,6E,\
00,64,00,6F,00,77,00,73,00,2E,00,45,00,78,00,70,00,6C,00,6F,00,72,00,65,00,\
72,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{A00C0AFC-E004-4024-9D25-52952AC99A6A}]
"VerCache"=hex(3):D7,6F,C4,71,5E,35,D4,01,00,8F,56,10,A0,E8,CA,01,00,00,00,\
00,00,40,02,00,33,00,13,00,07,00,00,00,33,00,13,00,07,00,00,00,09,04,00,00
"Flags"=-
"Version"=-

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ext\Stats\{A00C0AFC-E004-4024-9D25-52952AC99A6A}\iexplore]
"Time"=hex(3):E2,07,08,00,04,00,10,00,0E,00,29,00,33,00,DD,02
"Blocked"=dword:00000007
"Count"=dword:00000010

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ext\Stats\{A00C0AFC-E004-4024-9D25-52952AC99A6A}\iexplore\AllowedDomains\fiservse.net]

Keep in mind, the "A00C0AFC-E004-4024-9D25-52952AC99A6A" part of the registry key names are the class ID for the addon I want. 请记住,注册表项名称的“ A00C0AFC-E004-4024-9D25-52952AC99A6A”部分是我想要的插件的类ID。

If you want to do what I did and you have the .OCX file (which is probably rare but hey), just move the OCX file to SysWOW64 and System32 (if on 64-bit machine), register them using regsvr32, and then make the registry edits. 如果您想做我做的事,并且拥有.OCX文件(这可能很少见,但是,嘿),只需将OCX文件移至SysWOW64和System32(如果在64位计算机上),使用regsvr32注册它们,然后制作注册表编辑。

You COULD just make the exact registry edits I made (editing the class ID and the "AllowedDomains" domain), but I honestly do not know how much else of the registry file I posted is individualized to my own needs. 您可以只进行我所做的确切注册表编辑(编辑类ID和“ AllowedDomains”域),但是老实说,我不知道我发布的注册表文件中有多少还可以根据我自己的需要进行个性化设置。

If you want to be 100% sure, I would personally Google for a free tool that can compare the registry (I used RegistryChangesView v1.07) and compare the registry before and after installing the addon manually, and then export the keys it added/changed. 如果您想百分百确定,我个人将为Google提供免费工具,该工具可以比较注册表(我使用RegistryChangesView v1.07)并在手动安装插件之前和之后比较注册表,然后导出添加的注册表项/改变。

Thank you all for the help I am sure you would had provided! 谢谢大家的帮助,我相信您会提供的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM