Please help by looking over this. I'm getting the error "System.UnauthorizedAccessException: Cannot Write to the Registry Key" I'm not sure that the path to the Terminal Server key is correct. I have admin rights and write access to the key. Thanks very much for any assistance (I'm a beginner if you can't tell..)
Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim servername As Stringservername = txtServername.Text
Dim options As ConnectionOptionsoptions =
New ConnectionOptionsoptions.Impersonation = ImpersonationLevel.Impersonate
options.Username = servername & "\administrator"
options.Password = "password"
Dim scope As ManagementScopescope =
New ManagementScope("\\" & servername & "\root\cimv2", options)scope.Options.EnablePrivileges =
Truescope.Connect()
If scope.IsConnected = True ThenMsgBox("CONNECTED")
End If Try Dim environmentKey As RegistryKeyenvironmentKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, servername).OpenSubKey("system\currentcontrolset\control\Terminal Server")
environmentKey.SetValue("fDenyTSConnections", "0")
Catch ex As Exception
MsgBox(ex.ToString)
End Try End Sub
Remotely enabling remote desktop with system.management problem
Basel Alnachef
Onder
Hi Ken,
Thanks for replying. It was running but I had the sub-key path wrong and had to use int(0) as the value because it was dword. Works great now.
Josh Horner