7

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

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

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

4

7 回答 7

4

MSDN

以编程方式添加站点

C#

于 2010-03-18T15:30:56.633 回答
3

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

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

于 2010-03-18T15:29:46.993 回答
1

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

总之,此代码使用 COM 库,您确实说过希望避免使用该库。但是,没有解决这种情况的方法。另一件要提的是,这段代码是用 C++ 编写的,因为编写它的人CorithMartin从 C# 移植了它。

#include "windows.h"
#include "stdafx.h"
#include "urlmon.h"
#using <mscorlib.dll>
#include <atldef.h>
#include <atlconv.h>
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"http://*.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;
}
于 2010-03-18T15:27:09.597 回答
1

它确实存在于注册表中,并且在那里进行了描述:

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

不过要小心 Vista 中的 UAC。处理起来真的很痛苦。

于 2010-03-18T15:31:06.620 回答
1

电源外壳

#Setting IExplorer settings
Write-Verbose "Now configuring IE"
#Add http://website.com as a trusted Site/Domain
#Navigate to the domains folder in the registry
set-location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set-location ZoneMap\Domains

#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
于 2014-12-09T13:13:29.213 回答
0

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

于 2010-03-18T15:33:33.797 回答
0

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

  1. 创建一个 .exe 以请求域(文本框),指定提供程序(作为复选框:全部、http、https、ftp)单击“将站点添加到受信任的站点”,然后执行以下操作:
  2. 在 C: 上创建一个临时文件夹作为“C:\TempTS\”
  3. 创建一个与此类似的 .bat 文件(“C:\TempTS\AddTrustedSites.bat”):

设置 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%

注册表编辑器 /s %regFile%

删除 %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 目录。

麦克斯普斯特

(又名 GNoter,TechStuffBC)

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

信用到期的信用:

regedit /s AddTrustedSite.reg

“/s”将取消确认对话框

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

还:

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

于 2011-09-06T20:40:49.177 回答