I'm trying to disable Internet Explorer 11 AutoComplete for usernames and passwords on forms using the Windows Registry in a c# application.
The following code works some times (browser stops asking to save passwords and the checkboxes in AutoComplete Settings is unchecked), and fails at other times (that is, no exceptions but the browser still asks if you want to save passwords, and the checkboxes in AutoComplete settings are checked).
My question:
Is there another key that controls password saving, or is it perhaps failing due to the user's privileges? Or am I assigning the wrong value to the subkeys? Why would it work sometimes and fail silently others?
Another question: If a website is running in compatibility view, which displays webpages as if they were viewed by an earlier version of the browser, does IE11 then use the registry keys from the older versions (eg, HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\AutoComplete?)
// Keys I am manipulating:
// HKCU\Software\Microsoft\Internet Explorer\Main\FormSuggest Passwords
// HKCU\Software\Microsoft\Internet Explorer\Main\FormSuggest PW Ask
// others?
RegistryKey regKey1 = default(RegistryKey);
regKey1 = Registry.CurrentUser.OpenSubKey(#"Software\Microsoft\Internet Explorer\Main", true);
regKey1.SetValue("FormSuggest Passwords", "no", RegistryValueKind.String);
regKey1.Close(); //are these values ok?
RegistryKey regKey2 = default(RegistryKey);
regKey2 = Registry.CurrentUser.OpenSubKey(#"Software\Microsoft\Internet Explorer\Main", true);
regKey2.SetValue("FormSuggest PW Ask", "no", RegistryValueKind.String);
regKey2.Close();
Edit:
I have since discovered several other registry items that appear related to Auto Complete, but it is unclear which version of Internet Explorer these apply to. It also seems very difficult to find information about IE 11 registry settings in general.
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\AutoComplete
HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel\FormSuggest
HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel\FormSuggest Password
Setting access control for the registry key might help to resolve your problem
example
string user = Environment.UserDomainName + "\\" + Environment.UserName;
RegistrySecurity regSecurity = new RegistrySecurity();
rs.AddAccessRule(new RegistryAccessRule(user,
RegistryRights.ReadKey | RegistryRights.WriteKey,
InheritanceFlags.None,
PropagationFlags.None,
AccessControlType.Allow));
RegistryKey regKey1 = null;
try
{
regKey1 = Registry.CurrentUser.OpenSubKey(#"Software\Microsoft\Internet Explorer\Main",
RegistryKeyPermissionCheck.Default, rs);
regKey1.SetValue("FormSuggest Passwords", "no",RegistryValueKind.String);
}
catch (Exception ex)
{
Console.WriteLine("\r\nUnable to read key: {0}", ex);
}
These keys are also accessed by Internet Explorer when internet options->autocomplete is loaded:
HKCU\Software\Microsoft\Internet Explorer\DomainSuggestion\Enabled
HKLM\Software\Microsoft\Internet Explorer\DomainSuggestion
HKCU\Software\Microsoft\Internet Explorer\Main\Use FormSuggest
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete
HKCU\Software\Policies\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete
Seems windows explorer and internet explorer share some autocomplete options.
You can use some registry monitoring tools to see what is being accessed in compatibility view. This is how I found these keys.
Related
I have created an application(windows) compiled with .NET 4.6.1 and used the FolderBrowserDialog object. When a button is pressed I execute this code:
FolderBrowserDialog folderbrowserdialog = new FolderBrowserDialog();
folderbrowserdialog.Description = "Custom Description";
if (folderbrowserdialog.ShowDialog() == DialogResult.OK)
{
filePath = folderbrowserdialog.SelectedPath ;
}
what i get from the folderbrowserdialog(like foto)
however ,the folder browserdialog is not showing the networks shared folder(that the purpose of my app) otherewise just the pc folders.
but what i want to get it is the network shared folders which could i also access from windows 10 like foto here:
notes to be marked:
i could not use the open file dialog cause i need the folder location.
i desgined the Appto be opened just like admin by adding manisfest so the app is always starting like admin.
the app should be comptiable with windows 10,7
note i know that i could try setting this registry option (could be broken in Win10):
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System
EnableLinkedConnections=1
but it does not make a sense to add this registry by every customer PC
so is there any tipps to show the network shared folders in FolderBrowserDialog ?
Finally after reading many topics i found that the only solution is to add a Registry key programmatically so here how to add specfic C# Registry Subkey with dword value:
i wrote a method wich could all use it
just to let you know after using it you have to restart the device after it ,it will work ;)
public void ConfigureWindowsRegistry()
{
RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); //here you specify where exactly you want your entry
var reg = localMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
if (reg == null)
{
reg = localMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
}
if (reg.GetValue("EnableLinkedConnections") == null)
{
reg.SetValue("EnableLinkedConnections", "1", RegistryValueKind.DWord);
MessageBox.Show(
"Your configuration is now created,you have to restart your device to let app work perfektly");
}
}
I had the same issue. The reason of the problem: I was using as an Administrator. The mapped drives are related to the user, so I tried to use as an normal user and I could see the mapped drives.
I can create a windows user as it is mentioned in the link here
so after creating the user, can i tell system to login with that particular username and password?
I shouldn't have to login manually. is it possible to do?
Manually we can do it.
You can use the registry to auto login a computer. The key you need is:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Change AutoAdminLogon to 1.
Set DefaultUserName and DefaultPassword to the accounts username and password.
If the values don't exist just create them. Usually AutoAdminLogon and DefaultUserName are already there but you may have to create DefaultPassword.
How we can do the same with c# and managed registry classes?
HOpe this method will work for xp
public static void WriteDefaultLogin(string usr, string pwd)
{
//creates or opens the key provided.Be very careful while playing with
//windows registry.
RegistryKey rekey = Registry.LocalMachine.CreateSubKey
("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
if (rekey == null)
Console.WriteLine
("There has been an error while trying to write to windows registry");
else
{
//these are our hero like values here
//simply use your RegistryKey objects SetValue method to set these keys
rekey.SetValue("AutoAdminLogon", "1");
rekey.SetValue("DefaultUserName", usr);
rekey.SetValue("DefaultPassword", pwd);
}
//close the RegistryKey object
rekey.Close();
}
but will this work for all windows OS?
Waht should i change to make it work for all windows OS? especially W10.
So, I have a task to:
1. Delete all settings in Internet Connection Properties
2. Set Use Automatic Configuration Script to my script
This is my code, and sometimes it works and values are in IE, and sometimes values are not in IE. I am frustrated with this hectic behavior and wondering where is my error (not in DNA ;))
RegistryKey registry = Registry.CurrentUser.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 0);
registry.Close();
RegistryKey registry2 = Registry.CurrentUser.OpenSubKey(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections", true);
registry2.DeleteValue("DefaultConnectionSettings", false);
registry2.Close();
RegistryKey registry3 = Registry.CurrentUser.OpenSubKey(
#"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
registry3.SetValue("AutoConfigURL", #"http://wwwwwwwww/configscript.pac", Microsoft.Win32.RegistryValueKind.String);
registry3.SetValue("ProxyEnable", 000000, RegistryValueKind.DWord);
registry3.Close();
I suspect that the issue you face has something to with stale values on the UI.
The quickest way to check whether your settings are "sticky" is to open Internet options and going to Lan settings directly from control panel.
The following command will launch "internet options"
control inetcpl.cpl
Further if your machine belongs to some corporate domains, there might be group policies set by admins that periodically enforces some values for these parameters.
In such cases, you might have to schedule a task for say every 10 minutes, and enforce values of your choice. (note: that is what I have been doing for quite some time)
I want to force the webbrowser to use IE10 in my c# winform application.
I know there are other questions like this but i've already read a lot of them and i don't know where i'm wrong.
This is my code:
RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
(#"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
registrybrowser.SetValue("myAppName", 0x02710, RegistryValueKind.DWord); //Even with QWord
I've tried different ways to set the value like:
registrybrowser.SetValue("myAppName", 1000, RegistryValueKind.DWord); //Even with QWord and String
registrybrowser.SetValue("myAppName", 1000); //even with 0x02710
I write it in the costructor of my main project before InitializeComponent().
I've got Admin permission set in the .manifest file
Thanks to all, BlackShawarna
EDIT: I discovered that the RegistryKey.SetValue(...); created a key in another path:
(#"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION")
even if my instruction said: Registry.LocalMachine.OpenSubKey
(#"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
I think it happens because IE10 works on 32bit mode. However I don't understand why it writes in that path even if i specified another one and, above all, why my application doesn't work even if I open Registry.LocalMachine.OpenSubKey(#"Software\Wow6432Node....");
If I run my program only in x64 mode, going to properties/build/x64, it won't write the key in my original path.
I had the same problem that my app wrote the value to "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION".
I changed LocalMachine to CurrentUser and now it works.
string executablePath = Environment.GetCommandLineArgs()[0];
string executableName = System.IO.Path.GetFileName(executablePath);
RegistryKey registrybrowser = Registry.CurrentUser.OpenSubKey
(#"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (registrybrowser == null)
{
RegistryKey registryFolder = Registry.CurrentUser.OpenSubKey
(#"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl", true);
registrybrowser = registryFolder.CreateSubKey("FEATURE_BROWSER_EMULATION");
}
registrybrowser.SetValue(executableName, 0x02710, RegistryValueKind.DWord);
registrybrowser.Close();
The executableName is something like "myAppName.exe"
Note: If the WebBrowser Controls inside a DLL you need to specify the hosting EXE's name whatever that might be, eg System.AppDomain.CurrentDomain.FriendlyName
FEATURE_BROWSER_EMULATION "myAppName.exe"=10000 (or 0x02710) and not 1000.
In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
It works for me
You've got to say 'myAppName.exe' not 'myAppName'
If you have control over the page being rendered (a intranet page for instance) and also of the application that renders the page using the WebBrowser control, you can specify a meta tag in the page
<meta http-equiv="X-UA-Compatible" content="IE=10" />
and make use of the WebBrowser control as needed. You must have IE 10 on the machine.
Just in case you want to emulate other versions of IE, you could simply replace "IE=10" with "IE=EmulateIE9", "IE=EmulateIE8" etc.
I have a issue reading a registry value programmatically using C#.
I looked into many sites and help but could not find any helpful.
I am able to access and read registry when I run VS in eleveated mode, but face issue when I run VS with out elevated mode.
Initially I started with the below code
byte[] val = (byte[])Registry.GetValue("HKEY_LOCAL_MACHINE\\Software\\MyServices\\Identity\\ASPNET_SETREG", "ValueName", 0);
This worked fine with elevated mode, but fails in non elevated mode.
Placed the attribute on top of the function
[RegistryPermissionAttribute(SecurityAction.Demand,Unrestricted=true)]
This did not help. Then Tried
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.AllFlags)]
Still did not work.
Now I Tried the below code...
RegistryKey key = Registry.LocalMachine;
RegistrySecurity rs = new RegistrySecurity();
rs = key.GetAccessControl();
string user = "DomainName\\Username";
rs.AddAccessRule(new RegistryAccessRule(user,
RegistryRights.ReadKey,
InheritanceFlags.None,
PropagationFlags.None,
AccessControlType.Allow));
key.SetAccessControl(rs);//Exception: "Attempted to perform an unauthorized operation."}
//RegistryKey key2 = key.OpenSubKey("Software\\MyServices\\Identity\\ASPNET_SETREG");
//RegistryKey key2 = key.OpenSubKey("Software\\MyServices\\Identity\\ASPNET_SETREG", false);
//RegistryKey key2 = key.OpenSubKey("Software\\MyServices\\Identity\\ASPNET_SETREG", RegistryKeyPermissionCheck.ReadSubTree);
RegistryKey key2 = key.OpenSubKey("Software\\MyServices\\Identity\\ASPNET_SETREG", RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadPermissions);
Commenting SetAccessControl and use any of the OpenSubkey option, I get Exception: "Requested registry access is not allowed."
I am badly stuckup and unable to proceed.
private RegistryKey keyR = Registry.CurrentUser.OpenSubKey("Software\\YourKey",true);
private RegistryKey keyW = Registry.CurrentUser.CreateSubKey("Software\\YourKey");
public string version
{
get { return keyR.GetValue("VERSION", "", RegistryValueOptions.DoNotExpandEnvironmentNames).ToString(); }
set { keyW.SetValue("VERSION", value, RegistryValueKind.String); }
}
I am using windows registry in this way. No problem...
The windows registry is basically a structured file system, and has permissions for keys and values.
You do not have the permissions set correctly on ...\MyServices\ or deeper keys - you have no permission to access those from your unprivileged process.
Either:
Those keys should be readable by anybody, so you should change the permissions to make them readable by everybody. Or -
Those keys were intentionally restricted for a good reason, and so they should not be readable by everybody, in which case your program should always run elevated.