zephirus Posted September 22, 2009 at 03:22 PM Report Share #288134 Posted September 22, 2009 at 03:22 PM Olá, Tenho o seguinte código para obter o valor da registry de uma máquina remota. Sub Button1Click(sender As Object, e As EventArgs) Dim environmentKey As RegistryKey ' Open HKEY_CURRENT_USER\Environment on a remote computer. environmentKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, txtIpAddress.Text).OpenSubKey("SOFTWARE\Siemens\TNMS\CurrentVersion") label2.Text = environmentKey.GetValue("DiskLabel") ' Close the registry key. environmentKey.Close() End Sub Para uma máquina que tentei funciona, mas para outras que tento dá este erro: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation. at Microsoft.Win32.RegistryKey.Win32ErrorStatic at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey at remoteGet.MainForm.Button1Click in \My Documents\SharpDevelop Projects\remoteGet\remoteGet\MainForm.vb:line 29 at System.Windows.Forms.Control.OnClick at System.Windows.Forms.Button.OnClick at System.Windows.Forms.Button.OnMouseUp at System.Windows.Forms.Control.WmMouseUp at System.Windows.Forms.Control.WndProc at System.Windows.Forms.ButtonBase.WndProc at System.Windows.Forms.Button.WndProc at ControlNativeWindow.OnMessage at ControlNativeWindow.WndProc at System.Windows.Forms.NativeWindow.DebuggableCallback at ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop at ThreadContext.RunMessageLoopInner at ThreadContext.RunMessageLoop at System.Windows.Forms.Application.Run at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run at remoteGet.My.MyApplication.Main in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 Ambas as máquinas estão no mesmo workgroup. Alguém sabe qual é o problema? Obrigado Link to comment Share on other sites More sharing options...
zephirus Posted September 22, 2009 at 04:23 PM Author Report Share #288140 Posted September 22, 2009 at 04:23 PM UPDATE: verifiquei agora que já tinha acedido às pastas partilhadas da máquina remota a que consegui aceder ao registo e nas outras nunca o tinha feito. Basicamente o que isto quer dizer é que eu já tinha inserido o user e password da máquina remota e daí conseguir obter a informação. De qualquer forma faz-me alguma confusão visto que há por ai muitos programas que até fazem o discovery de máquinas na rede e obtém toda a informação que querem. Como é que o fazem? Não é suposto ser preciso dar credenciais? Link to comment Share on other sites More sharing options...
zephirus Posted September 23, 2009 at 09:20 AM Author Report Share #288256 Posted September 23, 2009 at 09:20 AM Alguém tem alguma pista de como se faz isto sem credenciais? Ou então existe outro método sem ser pelo registo... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now