Maxim Petrov
Maxim Petrov

Reputation: 309

How disable window when start IE

I need write functional for coded UI test, which disable popup, when open first time the browser Internet explorer. So how can I do this programmatically on c#? Is it need edit some register? enter image description here

Upvotes: 4

Views: 130

Answers (1)

user3473830
user3473830

Reputation: 7285

Based on http://www.petenetlive.com/KB/Article/0000175.htm we should set a registry key as:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Main] "DisableFirstRunCustomize"=dword:00000001

in C#, we should be able to do it like:

var key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true)
    .OpenSubKey("Policies", true)
    .OpenSubKey("Microsoft", true);

    key = key.OpenSubKey("Internet Explorer", true) ?? key.CreateSubKey("Internet Explorer", RegistryKeyPermissionCheck.ReadWriteSubTree);
    key = key.OpenSubKey("Main", true) ?? key.CreateSubKey("Main", RegistryKeyPermissionCheck.ReadWriteSubTree);
    key.SetValue("DisableFirstRunCustomize", 1, RegistryValueKind.DWord);

Upvotes: 1

Related Questions