日期:2014-05-17  浏览次数:20919 次

Window2000如何用脚本创建FTP服务
WIN2003里自带的iisftp.vbs很好用。但一直没找到WIN2000如何用。
不知道下面可用否?
1.将下面的代码另存为 Mkftpsite.vbs %SystemDrive%\InetPub\AdminScripts 文件夹中:
VBScript code


'------------------------
'
' This is a simple script to create a new virtual FTP server.
'
' Call this script with "-?" for usage instructions
'
'------------------------

' Force explicit declaration of all variables
Option Explicit

On Error Resume Next

Dim bArgStart
Dim bVerbose
Dim iArgPort
Dim iArgSiteNumber
Dim iArgNum
Dim oArgs
Dim szArgComputers
Dim szArgIPAddress
Dim szArgRootDirectory
Dim szArgServerComment

bArgStart = True
bVerbose = False
iArgPort = 21
iArgSiteNumber = 0
szArgIPAddress = ""
szArgComputers = Array(1)
szArgComputers(0) = "LocalHost"

Set oArgs = WScript.Arguments
iArgNum = 0

While iArgNum < oArgs.Count

  Select Case LCase(oArgs(iArgNum))
    Case "-o","--port":
      iArgNum = iArgNum + 1
      iArgPort = oArgs(iArgNum)  
    Case "-i","--ipaddress":
      iArgNum = iArgNum + 1
      szArgIPAddress = oArgs(iArgNum)
    Case "-r","--rootdirectory":
      iArgNum = iArgNum + 1
      szArgRootDirectory = oArgs(iArgNum)
    Case "-t","--comment":
      iArgNum = iArgNum + 1
      szArgServerComment = oArgs(iArgNum)
    Case "-c","--computer":
      iArgNum = iArgNum + 1
      szArgComputers = Split(oArgs(iArgNum),",",-1)
    Case "-n","--sitenumber":
      iArgNum = iArgNum + 1
      iArgSiteNumber = CLng(oArgs(iArgNum))
    Case "-d","--dontstart":
      bArgStart = False
    Case "-?","--help":
      Call DisplayUsage
    Case "-v","--verbose":
      bVerbose = True
    Case Else:
      WScript.Echo "Unknown argument " & oArgs(iArgNum)
      Call DisplayUsage
  End Select  

  iArgNum = iArgNum + 1
Wend

If (szArgRootDirectory = "") Or (szArgServerComment = "") Then
  If (szArgRootDirectory = "") Then
    WScript.Echo "Missing Root Directory"
  Else
    WScript.Echo "Missing Server Comment"
  End If
  Call DisplayUsage
  WScript.Quit(1)
End If

Call ASTCreateFtpSite(szArgIPAddress, szArgRootDirectory, szArgServerComment, iArgPort, szArgComputers, iArgSiteNumber, bArgStart)

Sub ASTCreateFtpSite(szIPAddress, szRootDirectory, szServerComment, iPortNum, szComputers, iSiteNumber, bStart)
  Dim bDone
  Dim iComputerIndex
  Dim iIndex
  Dim oFtpServer
  Dim oFtpSite
  Dim oMsFtpSvc
  Dim oNewFtpServer
  Dim oNewDir
  Dim szBindings
  Dim szBindingString
  Dim szComp
  Dim szNewBindings

  On Error Resume Next

  For iComputerIndex = 0 To UBound(szComputers)
    szComp = szComputers(iComputerIndex)
    If iComputerIndex <> UBound(szComputers) Then
      Trace "Creating FTP site on " & szComp & "."
    End If

    ' Grab the ftp service object
    Err.Clear
    Set oMsFtpSvc = GetObject("IIS://" & szComp & "/MSFTPSVC")
    If Err.Number <> 0 Then
      Display "Unable to open: " & "IIS://" & szComp & "/MSFTPSVC"
    End If

    szBindingString = szIPAddress & ":" & iPortNum & ":"
    Trace "Making sure this FTP server doesn't conflict with another..."
    For Each oFtpServer in oMsFtpSvc
      If oFtpServer.Class = "IIsFtpServer" Then
        szBindings = oFtpServer.ServerBindings
        If szBindingString = szBindings(0) Then
          Display "The server bindings you specified are duplicated in another virtual FTP server."
          WScript.Quit (1)
        End If
      End If
    Next

    iIndex = 1
    bDone = False
    Trace "Creating new FTP