博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自动更改Iexplore的Active x设置,添加可信站点,允许弹窗,自动清理
阅读量:5292 次
发布时间:2019-06-14

本文共 10843 字,大约阅读时间需要 36 分钟。

判断项有Active x,可信站点,阻止弹窗,每次退出清理

实现登录系统时进行判断,不满足时自动运行批处理文件修改IE设置,重启浏览器并返回登录页

————————————

//获取注册表数值数据 判断注册表Range100项是否存在    private bool IsRegeditItemExist()    {        string[] subkeyNames;        RegistryKey hkml = Registry.CurrentUser;        RegistryKey software = hkml.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges");        subkeyNames = software.GetSubKeyNames();        foreach (string keyName in subkeyNames)        {            if (keyName == "Range100")            //判断子项            {                hkml.Close();                return true;            }        }        hkml.Close();        return false;    }    //获取Activex+弹窗+可信站点注册表数值数据    protected string regeditGetValue(string str, string url)    {        string registData;        RegistryKey hkml = Registry.CurrentUser;        RegistryKey software = hkml.OpenSubKey("SOFTWARE", true);        RegistryKey aimdir = software.OpenSubKey(url, true);        registData = aimdir.GetValue(str).ToString();        return registData;    }    //弹窗显示    protected bool MessageIf()    {        System.Windows.Forms.DialogResult dr2 = System.Windows.Forms.MessageBox.Show("将运行配置文件,运行完毕后将自动重启浏览器,是否继续",                               "系统异常",                               System.Windows.Forms.MessageBoxButtons.OKCancel,                               System.Windows.Forms.MessageBoxIcon.Warning,                               System.Windows.Forms.MessageBoxDefaultButton.Button2,                               System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);        if (dr2 == System.Windows.Forms.DialogResult.OK)        {            return true;        }        else        {            return false;        }    }    //运行.bat文件    private void RunBat(string batPath)    {        Process pro = new Process();        FileInfo file = new FileInfo(batPath);        pro.StartInfo.WorkingDirectory = file.Directory.FullName;        pro.StartInfo.FileName = batPath;        pro.StartInfo.CreateNoWindow = false;        pro.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;        pro.Start();        pro.WaitForExit();    }    //执行文件    protected void RunAndReStart()    {        try        {            //批处理文件路径以及返回的登录页面要自己设置            RunBat(@"E:\Alroy\client\IERegSet.bat");            foreach (System.Diagnostics.Process s in System.Diagnostics.Process.GetProcessesByName("iexplore"))            {                s.Kill();            }            Thread.Sleep(1 * 1000);            System.Diagnostics.Process.Start("http://localhost:4920/BZ/Login.aspx");        }        catch        {            MessageBox.Show(this, "配置文件丢失,请联系管理员");        }    }
View Code
//判断是否运行配置文件    protected void LoadJudge()    {        string wb = "Microsoft\\Internet Explorer\\New Windows";        string tp = "Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range100";        string z3 = "Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3";        string z2 = "Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\2";        string pr = "Microsoft\\Internet Explorer\\Privacy";        if (IsRegeditItemExist() == true)        {            //activex+可信站点+弹窗判断            if (Convert.ToInt32(regeditGetValue("ClearBrowsingHistoryOnExit",pr)) != 1 ||                Convert.ToInt32(regeditGetValue("CleanPassword",pr)) != 1 ||                Convert.ToInt32(regeditGetValue("CleanHistory", pr)) != 1 ||                Convert.ToInt32(regeditGetValue("CleanForms", pr)) != 1 ||                Convert.ToInt32(regeditGetValue("CleanDownloadHistory", pr)) != 1 ||                Convert.ToInt32(regeditGetValue("CleanCookies", pr)) != 1 ||                 Convert.ToInt32(regeditGetValue("PopupMgr", wb)) != 0 ||                regeditGetValue(":Range", tp) != "localhost:192.168.1.118:81" ||                 Convert.ToInt32(regeditGetValue("http", tp)) != 2 ||                 Convert.ToInt32(regeditGetValue("120A", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("2702", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("120B", z2)) != 3 ||                 Convert.ToInt32(regeditGetValue("2300", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("2201", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("2000", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1405", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1402", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1209", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1208", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1206", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1201", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1200", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1004", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1001", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1400", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("2004", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("2001", z2)) != 0 ||                 Convert.ToInt32(regeditGetValue("1405", z3)) != 0 ||                 Convert.ToInt32(regeditGetValue("1201", z3)) != 1 ||                 Convert.ToInt32(regeditGetValue("1004", z3)) != 1 ||                 Convert.ToInt32(regeditGetValue("1001", z3)) != 1 ||                 Convert.ToInt32(regeditGetValue("1200", z3)) != 0 ||                 Convert.ToInt32(regeditGetValue("1208", z3)) != 0 ||                 Convert.ToInt32(regeditGetValue("2201", z3)) != 0)            {                if (MessageIf() == true)                {                    RunAndReStart();                }            }        }        else        {            if (MessageIf() == true)            {                RunAndReStart();            }        }    }
View Code

————————————

批处理文件:

可信站点要手动写入

@echo off &title By - CQPoyan@echo "============================"@echo " 设置可信站点"@echo " "reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range100" /v "http" /t REG_DWORD /d "00000002" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range100" /v ":Range" /t REG_SZ /d "localhost:192.168.1.118:81" /f@echo "============================"@echo " 修改ActiveX 控件和插件2"@echo " "reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2001" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2004" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1400" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1001" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1004" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1200" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1201" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1206" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1208" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1209" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1402" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1405" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2000" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2201" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2300" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "2702" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "120B" /t REG_DWORD /d "00000003" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "120A" /t REG_DWORD /d "00000000" /f@echo "============================"@echo " 修改ActiveX 控件和插件3"@echo " "reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1405" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1201" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1004" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1001" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1200" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1208" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "2201" /t REG_DWORD /d "00000000" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows" /v "PopupMgr" /t REG_DWORD /d "00000000" /f@echo "============================"@echo " 修改自动清理"@echo " "reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "CleanCookies" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "CleanDownloadHistory" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "CleanForms" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "CleanHistory" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "CleanPassword" /t REG_DWORD /d "00000001" /freg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Privacy" /v "ClearBrowsingHistoryOnExit" /t REG_DWORD /d "00000001" /f
View Code

 

转载于:https://www.cnblogs.com/Alphonso/p/6121459.html

你可能感兴趣的文章
opencv安装配置
查看>>
JAVA-初步认识-第六章-面向对象(举例)
查看>>
js合并数组
查看>>
cNoteSetCursor_命令窗口光标设置
查看>>
[Flex] flex手机项目如何限制横竖屏?只允许横屏?
查看>>
tensorflow的graph和session
查看>>
Benelux Algorithm Programming Contest 2014 Final(第二场)
查看>>
随机变量的期望为什么把不是自己密度函数当成自己的权重来求期望呢?
查看>>
6-1 并行程序模拟 uva210
查看>>
JavaScript动画打开半透明提示层
查看>>
Mybatis生成resulteMap时的注意事项
查看>>
jquery-jqzoom 插件 用例
查看>>
javascript知识点记录01
查看>>
javascript事件代理
查看>>
es6 新增特性
查看>>
1007. Maximum Subsequence Sum (25)
查看>>
《算法》C++代码 快速排序
查看>>
iframe的父子层跨域 用了百度的postMessage()方法
查看>>
Js apply方法与call方法详解 附ES6新写法
查看>>
linux php全能环境一键安装,小白福利!
查看>>