Solved get remote registry keys

Posted on 2009-02-12
Last Modified: 2012-05-06
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...


            Dim connection As New ConnectionOptions

            connection.Username = "username"

            connection.Password = "myPassword"

            connection.Authority = "

            Dim scope As New ManagementScope( _

                "\\MYCOMPUTERNAME\root\DEFAULT", connection)


            '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 = _


            ' 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

Question by:ceMo89
    LVL 3

    Accepted Solution

    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...
    Dim manPath As ManagementPath = New ManagementPath("StdRegProv")
    Dim classInstance As New ManagementObject(scope, manPath, Nothing)

    Open in new window

    LVL 3

    Expert Comment

    Hi ceMo89,

    Did you get anywhere with this?


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now