• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 755
  • Last Modified:

vb.net get remote registry keys

Hey gus's,

can someone tell me what is wrong in my code below????

I'll get everytime the same error at:
Dim classInstance As New ManagementObject(scope, New ManagementPath("StdRegProv"), Nothing)
--> Specified argument was out of the range of valid values. Parameter name: path

I don't have any ideas...
Please help me...

Thanks
ceMo
Try
            Dim connection As New ConnectionOptions
            connection.Username = "username"
            connection.Password = "myPassword"
            connection.Authority = "ntlmdomain:mydomain.de
 
            Dim scope As New ManagementScope( _
                "\\MYCOMPUTERNAME\root\DEFAULT", connection)
            scope.Connect()
 
            'Dim classInstance As New ManagementObject(scope, New ManagementPath("StdRegProv"), Nothing)
            Dim classInstance As New ManagementObject(scope, New ManagementPath("StdRegProv"), Nothing)
 
            ' Obtain [in] parameters for the method
            Dim inParams As ManagementBaseObject = _
                classInstance.GetMethodParameters("GetDWORDValue")
 
            ' Add the input parameters.
            inParams("hDefKey") = -2147483646
            inParams("sSubKeyName") = "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile"
            inParams("sValueName") = "DisableNotifications"
 
            ' Execute the method and obtain the return values.
            Dim outParams As ManagementBaseObject = _
                classInstance.InvokeMethod("GetDWORDValue", inParams, Nothing)
 
            ' List outParams
            Console.WriteLine("Out parameters:")
            Console.WriteLine("ReturnValue: {0}", outParams("ReturnValue"))
            Console.WriteLine("uValue: {0}", outParams("uValue"))
 
        Catch err As ManagementException
 
            MessageBox.Show("An error occurred while trying to execute the WMI method: " & err.Message)
 
        Catch unauthorizedErr As System.UnauthorizedAccessException
 
            MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message)
        End Try

Open in new window

0
ceMo89
Asked:
ceMo89
  • 2
1 Solution
 
ajnt__Commented:
Hi ceMo89,

Can you try changing the code like below please and posting back the value of the "New ManagementPath("StdRegProv")" code as this is what's causing the problem.

Also you might find these articles of use...

http://www.pcreview.co.uk/forums/thread-531796.php
http://social.microsoft.com/Forums/en-US/netfxbcl/thread/0cf22b86-8efc-4231-92f9-3dd23db7f8cf
Dim manPath As ManagementPath = New ManagementPath("StdRegProv")
Dim classInstance As New ManagementObject(scope, manPath, Nothing)
 

Open in new window

0
 
ajnt__Commented:
Hi ceMo89,

Did you get anywhere with this?

Ajnt
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now