Csharp/C#教程:如何在Internet Explorer中将URL添加到受信任区域?分享


如何在Internet Explorer中将URL添加到受信任区域?

如何将URL添加到受信任的站点? 似乎存储在注册表中,但究竟在哪里?
到目前为止,我用Google搜索的提示并没有帮助。

.net程序将在每个客户端上本地运行。

编辑说明 :我想以编程方式运行C#代码。

以下应该为您提供在代码中执行此操作的方法…

https://blogs.msdn.com/ie/archive/2005/01/26/361228.aspx

MSDN

以编程方式添加网站

C#

它确实在注册表中,并在那里描述:

https://msdn.microsoft.com/en-us/library/ms537181%28VS.85%29.aspx

但请注意Vista中的UAC。 处理真的很痛苦。

在CodeGuru论坛上查看此解决方案 。

总而言之,这段代码使用了COM库,这是一个你曾希望避免使用的库。 但是,这种情况没有解决方法。 另一件值得提到的是,这段代码是用C ++编写的,就像编写它的人一样, CorithMartin从C#移植它。

#include "windows.h" #include "stdafx.h" #include "urlmon.h" #using  #include  #include  using namespace System; using namespace System::Runtime::InteropServices; #define MAX_LOADSTRING 100 int _tmain(int argc, _TCHAR* argv[]) { // constants from urlmon.h const int URLZONE_LOCAL_MACHINE = 0; const int URLZONE_INTRANET = URLZONE_LOCAL_MACHINE + 1; const int URLZONE_TRUSTED = URLZONE_INTRANET + 1; const int URLZONE_INTERNET = URLZONE_TRUSTED + 1; const int URLZONE_UNTRUSTED = URLZONE_INTERNET + 1; const int URLZONE_ESC_FLAG = 0x100; const int SZM_CREATE = 0; const int SZM_DELETE = 0x1; HRESULT hr; IInternetSecurityManager *pSecurityMgr; LPCWSTR sites = SysAllocString(L"https://*.mydomain.com"); CoInitialize(NULL); hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, (void**)&pSecurityMgr); pSecurityMgr->SetZoneMapping(URLZONE_TRUSTED, sites, SZM_CREATE); pSecurityMgr->Release(); return 0; } 

电源shell

 #Setting IExplorer settings Write-Verbose "Now configuring IE" #Add https://website.com as a trusted Site/Domain #Navigate to the domains folder in the registry set-location "HKCU:SoftwareMicrosoftWindowsCurrentVersionInternet Settings" set-location ZoneMapDomains #Create a new folder with the website name new-item website/ -Force set-location website/ new-itemproperty . -Name * -Value 2 -Type DWORD -Force new-itemproperty . -Name http -Value 2 -Type DWORD -Force new-itemproperty . -Name https -Value 2 -Type DWORD -Force 

要添加新的受信任区域,它会在路径HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Internet Settings ZoneMap Domains上为每个域创建一个区域注册表项和文件夹,它会创建一个带有域名的新密钥(sample.com)一个新的在这个带有子域(www)的密钥下,在这个下面有一个新的REG_DWORD,在hex上有一个方案名称(http或https)值2,就是这样,你完成了它

这是一种简化流程的方法。

  1. 创建.exe以请求域(文本框),指定提供者(如复选框:All,http,https,ftp)单击“将站点添加到可信站点”,然后执行以下操作:
  2. 在C上创建一个临时文件夹:“C: TempTS ”
  3. 创建一个.bat文件(“C: TempTS AddTrustedSites.bat”),类似于:

set regFile =“C: TempTS AddTrustedSiteTS.reg”

ECHO Windows注册表编辑器版本5.00>%regFile%

ECHO [HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Internet Settings ZoneMap Domains MySecureDomain.com www] >>%regFile

ECHO“https”= dword:00000002 >>%regFile%

regedit / s%regFile%

DEL%regFile%

对于每个检查的提供者,可以重复ECHO [HKEY_CURRENT_USER …ECHO“https”…行。 对于“ALL”提供程序,使用星号代替“https”,如下所示:

ECHO [HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Internet Settings ZoneMap Domains MySecureDomain.com www] >>%regFile%ECHO“*”= dword:00000002 >>%regFile%

使用此调用运行.bat文件:

System.Diagnostics.Process.Start( “C: TEMPTS AddTrustedSites.bat”)

运行.bat文件(仅需几微秒)后,删除bat文件和tempTS目录。

MacSpudster

(又名GNoter,TechStuffBC)

=========================

信用到期的信用:

regedit / s AddTrustedSite.reg

“/ s”将禁止确认对话框

https://www.computerhope.com/registry.html

也:

请参阅https://www.computing.net/answers/windows-xp/bat-file-to-add-trusted-site-in-ie/139995.html

上述就是C#学习教程:如何在Internet Explorer中将URL添加到受信任区域?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1022908.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

精彩推荐