E
Eric Dropps
Hello all,
Having a problem with SetComputerNameEx() -- the API says it returns 0 on
failure, but for me it is always returning a random number on failure or
success. Interestingly though, the code is working in terms of renaming a
computer, assuming the new name is valid. How can i check to see if the
name is invalid, since the function is always returning a non-zero value?
Sample Code Below:
Private Sub RenameComputer(ByVal strNewName)
Dim RtrnVal
RtrnVal =
SetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname,
strNewName)
MsgBox(RtrnVal)
If RtrnVal = 0 Then
MsgBox("Error: Could not rename computer. Check to make sure the computer
name does not contain spaces, symbols, or punctuation.")
myCaller.LblStatus.Text = "There was an error renaming the computer"
Else
myCaller.LblStatus.Text = "Computer renamed successfully. Please reboot to
continue."
myCaller.JoinDomainButton.Enabled = False
myCaller.DeptsBox.Enabled = False
End If
End Sub
Eric Dropps
Jr. Systems Administrator
Harvard University FAS Computer Services
(e-mail address removed) 617.495.9768
Having a problem with SetComputerNameEx() -- the API says it returns 0 on
failure, but for me it is always returning a random number on failure or
success. Interestingly though, the code is working in terms of renaming a
computer, assuming the new name is valid. How can i check to see if the
name is invalid, since the function is always returning a non-zero value?
Sample Code Below:
Private Sub RenameComputer(ByVal strNewName)
Dim RtrnVal
RtrnVal =
SetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname,
strNewName)
MsgBox(RtrnVal)
If RtrnVal = 0 Then
MsgBox("Error: Could not rename computer. Check to make sure the computer
name does not contain spaces, symbols, or punctuation.")
myCaller.LblStatus.Text = "There was an error renaming the computer"
Else
myCaller.LblStatus.Text = "Computer renamed successfully. Please reboot to
continue."
myCaller.JoinDomainButton.Enabled = False
myCaller.DeptsBox.Enabled = False
End If
End Sub
Eric Dropps
Jr. Systems Administrator
Harvard University FAS Computer Services
(e-mail address removed) 617.495.9768