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.

97 lines
2.4 KiB

  1. '------------------------------------------------------------------------------------------------
  2. '
  3. ' Usage: stopftp <--ADSPath|-a server1[,server2,server3...]>
  4. ' [--computer|-c COMPUTER1[,COMPUTER2...]]
  5. ' [--verbose|-v]
  6. ' [--help|-?]
  7. '
  8. ' SERVERx FTP Server # to be stopped
  9. '
  10. ' Example 1: stopftp --a 3,1
  11. '------------------------------------------------------------------------------------------------
  12. ' Force explicit declaration of all variables.
  13. Option Explicit
  14. On Error Resume Next
  15. Dim oArgs, ArgNum, ArgServerList
  16. Dim verbose
  17. Dim ArgComputers
  18. ArgComputers = Array("LocalHost")
  19. verbose = false
  20. Set oArgs = WScript.Arguments
  21. ArgNum = 0
  22. While ArgNum < oArgs.Count
  23. Select Case LCase(oArgs(ArgNum))
  24. Case "--adspath","-a":
  25. ArgNum = ArgNum + 1
  26. ArgServerList=Split(oArgs(ArgNum), ",", -1)
  27. Case "--computer","-c":
  28. ArgNum = ArgNum + 1
  29. ArgComputers = Split(oArgs(ArgNum), ",", -1)
  30. Case "--verbose", "-v":
  31. verbose = true
  32. Case "--help","-?":
  33. Call DisplayUsage
  34. Case Else:
  35. Call DisplayUsage
  36. End Select
  37. ArgNum = ArgNum + 1
  38. Wend
  39. If Not IsArray(ArgServerList) Then
  40. Call DisplayUsage
  41. End If
  42. Dim compIndex
  43. for compIndex = 0 to UBound(ArgComputers)
  44. Call ASTStopFtpServers(ArgComputers(compIndex),ArgServerList)
  45. next
  46. Sub ASTStopFtpServers(Computer, ServerList)
  47. Dim ServerNum, oServer
  48. On Error Resume Next
  49. ServerNum = 0
  50. Dim fullPath
  51. While ServerNum <= UBound(ServerList)
  52. fullPath = "IIS://"&Computer&"/msftpsvc/"&ArgServerList(ServerNum)
  53. Trace "Stopping " & fullPath & "."
  54. Set oServer = GetObject(fullPath)
  55. If Err <> 0 Then
  56. Display "Unable to open " & fullPath & "."
  57. End If
  58. oServer.Stop
  59. If Err <> 0 Then
  60. Display "Unable to stop ftp server " & fullPath & "."
  61. End If
  62. ServerNum = ServerNum + 1
  63. Wend
  64. End Sub
  65. Sub Display(Msg)
  66. WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
  67. End Sub
  68. Sub Trace(Msg)
  69. if verbose = true then
  70. WScript.Echo Now & " : " & Msg
  71. end if
  72. End Sub
  73. Sub DisplayUsage
  74. WScript.Echo "Usage: stopftp <--ADSPath|-a server1[,server2,server3...]>"
  75. WScript.Echo " [--computer|-c COMPUTER1[,COMPUTER2...]]"
  76. WScript.Echo " [--verbose|-v]"
  77. WScript.Echo " [--help|-?]"
  78. WScript.Echo "Note: server1, server2, etc. is the number of the server"
  79. WScript.Echo "Example 1: stopftp -a 1,2,5"
  80. WScript.Echo "Example 2: stopftp -c MACHINE1,MACHINE2,MACHINE3 -a 1,2,5"
  81. WScript.Quit (1)
  82. End Sub