Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

  1. '
  2. ' Test IConfigureYourServer::ValidateName
  3. '
  4. option explicit
  5. // this is a Visual Basic Script "Template", used in conjunction with the
  6. // MS Visual C++ Preprocessor to overcome some of the source management
  7. // limitations of VBScript. Not perfect, but better than a stick in the eye.
  8. //
  9. // use cl /EP foo.vbt > foo.vbs to expand the template
  10. const SCRIPT_FILENAME = "test-ValidateName.vbs"
  11. const SCRIPT_SOURCE_NAME = __FILE__
  12. const SCRIPT_DATE = __DATE__
  13. const SCRIPT_TIME = __TIME__
  14. // this is all our common code.
  15. #include "common.vbi"
  16. Main
  17. wscript.quit(0)
  18. sub Main
  19. On Error Resume Next
  20. if wscript.arguments.count <> 1 then
  21. Echo "supply a name to validate"
  22. Exit sub
  23. end if
  24. Echo "Validating " & wscript.arguments.item(0)
  25. Dim srvwiz
  26. Set srvwiz = CreateObject("ServerAdmin.ConfigureYourServer")
  27. Dim nameTypes(1)
  28. nameTypes(0) = "DNS"
  29. nameTypes(1) = "NetBios"
  30. Dim resultCodes(6)
  31. resultCodes(0) = "Illegal Input"
  32. resultCodes(1) = "Name Too Long"
  33. resultCodes(2) = "Numeric Name"
  34. resultCodes(3) = "Name Contains Bad Characters"
  35. resultCodes(4) = "Malformed Name"
  36. resultCodes(5) = "Name Valid, In Use"
  37. resultCodes(6) = "Name Valid, Available"
  38. Dim i
  39. Dim j
  40. For i = 0 to Ubound(nameTypes)
  41. Err.Clear
  42. Echo "Validating " & wscript.arguments.item(0) & " as " & nameTypes(i)
  43. j = srvWiz.ValidateName(nameTypes(i), wscript.arguments.item(0))
  44. If Err.Number then DumpErrAndQuit
  45. Echo j
  46. Echo resultCodes(j)
  47. Next
  48. End sub