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



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?

.



Relevant Pages

  • Re: How Can I Read a Web Page?
    ... I always do searches before posting a ... >> Imports System.Net ... >> Public Function LoadTextFile(ByVal Url As String) As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: - How do I rename print-to-file filename at runtime?
    ... Is there a way to rename printer file port name at runtime BEFORE (not ... > pFrom As String ... > "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long ...
    (microsoft.public.vb.winapi)
  • Re: Renaming linked tables
    ... Dim myuserid, mypswrd, mydsn As String ... BTW, where have you declared such variables as dbs, temprst, tbl and tblo? ... Doug Steele, Microsoft Access MVP ... I'll like to rename each table right after the linking for each one. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Replicated DB and synchronize with PPC with active Sync
    ... This posting is provided "AS IS" with no warranties, ... > How did you convert the s_Guid into String? ... >>> Globalization Infrastructure and Font Technologies ...
    (microsoft.public.access.replication)
  • RE: Possible?
    ... declare @ptr binary ... -- Export the table using comma as the row terminator. ... -- Return the string as a result set. ... This posting is provided "as is" with no warranties and confers no rights. ...
    (microsoft.public.sqlserver.programming)