Hello all,
Having a problem with SetComputerName Ex() -- 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 =
SetComputerName Ex(COMPUTER_NAM E_FORMAT.Comput erNamePhysicalD nsHostname,
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.LblSta tus.Text = "There was an error renaming the computer"
Else
myCaller.LblSta tus.Text = "Computer renamed successfully. Please reboot to
continue."
myCaller.JoinDo mainButton.Enab led = False
myCaller.DeptsB ox.Enabled = False
End If
End Sub
Eric Dropps
Jr. Systems Administrator
Harvard University FAS Computer Services
dropps@fas.harv ard.edu 617.495.9768
Having a problem with SetComputerName Ex() -- 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 =
SetComputerName Ex(COMPUTER_NAM E_FORMAT.Comput erNamePhysicalD nsHostname,
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.LblSta tus.Text = "There was an error renaming the computer"
Else
myCaller.LblSta tus.Text = "Computer renamed successfully. Please reboot to
continue."
myCaller.JoinDo mainButton.Enab led = False
myCaller.DeptsB ox.Enabled = False
End If
End Sub
Eric Dropps
Jr. Systems Administrator
Harvard University FAS Computer Services
dropps@fas.harv ard.edu 617.495.9768
Comment