1
VB.net應用程序啓動當我嘗試設置/打開註冊表鍵我有例外:在啓動
Requested registry access is not allowed.
我可以設置requestedExecutionLevel
關鍵requireAdministrator
,但我不希望每次應用程序啓動時請參閱管理提示。而有些用戶沒有管理員權限。它將完美地按需要求管理員權限。
碼對於我已經嘗試過:
Dim regStartUp As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
Dim value As String
value = regStartUp.GetValue("App")
If value <> Application.ExecutablePath.ToString() & " startup" Then
regStartUp.CreateSubKey("App")
regStartUp.SetValue("App", Application.ExecutablePath.ToString() & " startup")
End If
Dim CommandLineArguments As String() = Environment.GetCommandLineArgs()
Dim i As Integer
Dim hideme As Boolean = False
For i = 0 To CommandLineArguments.GetUpperBound(0)
Console.WriteLine(CommandLineArguments(i) & vbCrLf)
If CommandLineArguments(i).ToLower() = "startup" Then
hideme = True
End If
Next
If hideme Then
Me.Hide()
End If
您正在對用戶的機器進行**重大**更改。這*要求*通過UAC提示告訴用戶。隱藏它對用戶希望保持其機器穩定性是一大損害。它不能工作,這是強制執行的。 –