通过C# 添加站点到IE信任列表

本文介绍了如何在非管理员权限的测试环境中,通过C#和Dotnetfactory库将特定站点添加到Internet Explorer的信任站点列表,以解决自动化脚本访问限制问题。
摘要由CSDN通过智能技术生成

某些测试环境下, 系统用户并非管理员权限,因此当自动化脚本尝试打开一些特殊站点时,需要将站点添加到系统信任列表才可以继续访问。

利用C#和Dotnetfactory,可以实现将站点添加到IE的信任列表的功能。


1, DLL 部分实现:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;

namespace Automation
{
    public class BrowserManager
    {
       
        #region AddTrustedSite
        public void AddTrustedSite(string domain,string subDomian,string siteType)
        {
            const string domainsKeyLocation = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains";
            //const string domainsKeyLocation = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains";
            //const string domain = @"newsite.com";
            const int trustedSiteZone = 0x2;

   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值