Home All Groups Group Topic Archive Search About

Remotely Rename a PC...getting encryption needed error.

Author
26 Jan 2006 7:24 PM
wade.blakeman
Hi,

I am new to programming and want to thank everyone for posting and
replying as most of my problem solving comes from here.  My issue that
I am unable to find a solution for is when I try to rename a PC
remotely.  This will be a utility for IT Techs to use to quickly,
easily and actually rename a PC.  I have a form created for user input
and use of a .txt file for many renames but I can't get the code to
make it actually rename the PC.  I found this posting and it helped
some but I am getting a System.Management.ManagementException that
says:

System.Management.ManagementException: Client connection to WINMGMT
needs to be encrypted for this operation. Please adjust your
IWbemServices proxy security settings and retry.
   at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
   at System.Management.ManagementObject.InvokeMethod(String
methodName, ManagementBaseObject inParameters, InvokeMethodOptions
options)
   at RenamePC.InputForm.Rename(Object strNewComputer, Object
strOldComputer, Object strModLocalUser, Object strLocalPasswd) in
C:\...\RenamePC\InputForm.vb:line 472

This is the code I am using:

    Public Function Rename(ByVal strNewComputer As String, ByVal
strOldComputer As String, ByVal strModLocalUser As String, ByVal
strLocalPasswd As String) As Integer

        Try
            Dim mComputerSystem As ManagementObject
            Dim mPath As New ManagementPath
            Dim inParams As ManagementBaseObject
            Dim outParams As ManagementBaseObject
            Dim enableprivileges As Boolean
            mPath.Server = strOldComputer
            mPath.NamespacePath = "root\CIMV2"
            mPath.RelativePath = "Win32_ComputerSystem.Name='" &
strOldComputer & "'"
            mComputerSystem = New ManagementObject(mPath)
            inParams = mComputerSystem.GetMethodParameters("Rename")
            inParams("Name") = strNewComputer
            inParams("UserName") = strModLocalUser
            inParams("Password") = strLocalPasswd
            outParams = mComputerSystem.InvokeMethod("Rename",
inParams, Nothing)

            Return Convert.ToInt32(outParams("ReturnValue"))

        Catch Ex As Exception
            '            TextBox.Text += Ex.ToString
            MsgBox(Ex.ToString)
            'Returning a non zero value to indicate rename failed
            Return 1
        End Try

    End Function


Any ideas on how to make this work?

AddThis Social Bookmark Button