打开IE设置-安全

1     dynamic shellObject = Interaction.CreateObject("WScript.Shell", "");
2 //打开IE设置-安全
3 shellObject.Run("Rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,1");
4 await Task.Delay(500);
5 //默认级别
6 shellObject.SendKeys("{TAB}");
7 shellObject.SendKeys("{TAB}");
8 shellObject.SendKeys("{TAB}");
9 shellObject.SendKeys("{TAB}");
10 shellObject.SendKeys("{R}");
11
12 await Task.Delay(100);
13 shellObject.SendKeys("{TAB}");
14 shellObject.SendKeys("{TAB}");
15 shellObject.SendKeys("{TAB}");
16 shellObject.SendKeys("{A}");
17
18 await Task.Delay(100);
19 shellObject.SendKeys("{ENTER}");

如上步骤如下,

  1. 打开IE设置-安全 Tab
  2. 等待窗口焦点转移(0.5ms) -- 因为当前的焦点,是在界面触发点位置,比如按钮。
  3. 模拟手动操作,将安全级别重置为默认级别
  4. 模拟手动操作,点击应用
  5. 关闭选项窗口

如上步骤中,等待的时间并非一定的,是个人根据调试结果,设置的一个貌似OK的值。

C# 重置IE安全等级_重置

 

Rundll32 Commands 列表参考:​​List of Rundll32 Commands in Windows 10​

Github地址:​​IE环境修复工具​


作者:唐宋元明清2188

本文版权归作者所有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。