簡體   English   中英

如何在Internet Explorer中將URL添加到受信任區域?

[英]How to add URL to the trusted zone in Internet Explorer?

如何將URL添加到受信任的站點? 似乎存儲在注冊表中,但究竟在哪里?
到目前為止我用Google搜索的提示都沒有用。

.net程序將在每個客戶端上本地運行。

編輯說明 :我想以編程方式運行C#代碼。

以下應該為您提供在代碼中執行此操作的方法...

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

在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;
}

它確實在注冊表中,並在那里描述:

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

但請注意Vista中的UAC。 處理真的很痛苦。

電源外殼

#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

要添加新的受信任區域,它會在路徑HKEY_CURRENT_USER \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Internet Settings \\ ZoneMap \\ Domains上為每個域創建一個區域注冊表項和文件夾,它會創建一個帶有域名的新密鑰(sample.com)一個新的在這個帶有子域(www)的密鑰下,在這個下面有一個新的REG_DWORD,在十六進制上有一個方案名稱(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”將禁止確認對話框

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

也:

請參閱http://www.computing.net/answers/windows-xp/bat-file-to-add-trusted-site-in-ie/139995.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM