Leaked source code of windows server 2003
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.

42 lines
1.2 KiB

  1. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2. ''
  3. '' DELCOMP.VBS
  4. ''
  5. '' Deletes the specified computer account from the specified container
  6. ''
  7. '' usage: delcomp container computername
  8. ''
  9. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  10. Option Explicit
  11. Dim oArgs
  12. Dim oContainer
  13. On Error Resume Next
  14. 'Stop
  15. Set oArgs = WScript.Arguments
  16. If (oArgs.Count <> 1) Then
  17. WScript.Echo "Usage: delcomp computername"
  18. WScript.Echo "Example: cscript delcomp.vbs chuckc0"
  19. WScript.Quit
  20. End If
  21. Set oContainer = GetObject("LDAP://ntdev.microsoft.com/CN=Computers,DC=ntdev,DC=microsoft,DC=com")
  22. If (Err.Number <> 0) Then
  23. WScript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred binding to container."
  24. WScript.Quit(Err.Number)
  25. End If
  26. oContainer.Delete "computer", "CN=" + oArgs(0)
  27. If (Err.Number = 0) Then
  28. Script.Echo "The computer account was deleted successfully."
  29. Else
  30. WScript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred deleting computer account."
  31. WScript.Quit(Err.Number)
  32. End If
  33. WScript.Quit(0)