以下是我试图使我的Windows桌面应用工作的步骤。在哪里需要编写FEATURE_BROWSER_EMULATION
。对于管理员用户来说工作正常,但对于没有权利在注册表中写入的标准用户而言失败。WPF C# - 在标准(非特权)用户的应用启动时在注册表中进行更改
1)我已设置<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
,以便用户在安装时拥有权限。
并且创建脚本并在安装时运行,由于此脚本无法安装应用程序。
On Error Resume Next
strComputer = "."
Const HKEY_LOCAL_MACHINE = &H80000002
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
Sub strLocalMachinePath1 = "SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"
objRegistry.OpenSubKey(HKEY_LOCAL_MACHINE, strLocalMachinePath1);
If objRegistry.GetValue("MyApp.exe") Is Nothing Then
objRegistry.SetValue("MyApp.exe", 8000)
End If
If objRegistry.GetValue("MyApp.vshost.exe") Is Nothing Then
objRegistry.SetValue("MyApp.vshost.exe", 11000)
End If
End Sub
2)我试图<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
其询问管理员密码,每次打开应用程序。对于不是管理员的标准用户来说,这会失败。
3)我试图写相同的App.xml.cs
- >App_Startup
- >
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true);
key.CreateSubKey("FeatureControl");
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl", true);
key.CreateSubKey("FEATURE_BROWSER_EMULATION");
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
但都没有区别。如果用户没有权限来启动的No Internet connection
var client = new WebClientPool().GetIdleWebClientObject()
我已经试过了,请检查问题的第三个点。在这种情况下,一旦我重新启动应用,它不允许我连接互联网。任何解决方法? – Heena
@Heena这里的互联网连接怎么样? – Evk
我不知道为什么。但是之后我在On_Startup中使用了Internet检查代码。像这样使用(var stream = client.OpenRead(“http://www.google.com”))使用(var client = new WebClient GetIdleWebClientObject()) { ) { return true; } }' – Heena