如何編寫一個創(chuàng)建FTP站點(diǎn)的函數(shù)?
Function ASTCreateFtpSite(IPAddress, RootDirectory, ServerComment, HostName, PortNum, Computer, Start,LogFileDirectory)
Dim MSFTPSVC, FtpServer, NewFtpServer, NewDir
Dim Bindings, BindingString, NewBindings, Index, SiteObj, bDone
On Error Resume Next
Err.Clear
Set MSFTPSVC = GetObject("IIS://" Computer "/MSFTPSVC")
If Err.Number > 0 Then
WScript.Echo "無法打開: ""IIS://" Computer "/MSFTPSVC" VbCrlf "程序?qū)⑼顺?/SPAN>!"
WScript.Quit (1)
End If
BindingString = IpAddress ":" PortNum ":" HostName
For Each FtpServer in MSFTPSVC
If FtpServer.Class="IIsFtpServer" Then
Bindings = FtpServer.ServerBindings
If BindingString = Bindings(0) Then
WScript.Echo "噢,IP地址沖突:" IpAddress ",請檢測IP地址!" VbCrlf "取消創(chuàng)建本站點(diǎn)."
Exit Function
End If
End If
Next
Index = 1
bDone = False
While (Not bDone)
Err.Clear
Set SiteObj = GetObject("IIS://"Computer"/MSFTPSVC/" Index)
If (Err.Number = 0) Then
Index = Index + 1
Else
Err.Clear
Set NewFtpServer = MSFTPSVC.Create("IIsFtpServer", Index)
If (Err.Number > 0) Then
Index = Index + 1
Else
Err.Clear
Set SiteObj = GetObject("IIS://"Computer"/MSFTPSVC/" Index)
If (Err.Number = 0) Then
bDone = True
Else
Index = Index + 1
End If
End If
End If
If (Index > 10000) Then
WScript.Echo "噢,創(chuàng)建站點(diǎn)異常!正在創(chuàng)建的站點(diǎn)的序號為:"Index"." VbCrlf "取消創(chuàng)建本站點(diǎn)."
Exit Function
End If
Wend
NewBindings = Array(0)
NewBindings(0) = BindingString
NewFtpServer.ServerBindings = NewBindings
NewFtpServer.ServerComment = ServerComment
NewFtpServer.AllowAnonymous = False
NewFtpServer.AccessWrite = True
NewFtpServer.AccessRead = True
NewFtpServer.DontLog = False
NewFtpServer.LogFileDirectory = LogFileDirectory
NewFtpServer.SetInfo
Set NewDir = NewFtpServer.Create("IIsFtpVirtualDir", "ROOT")
NewDir.Path = RootDirectory
NewDir.AccessRead = true
Err.Clear
NewDir.SetInfo
If (Err.Number = 0) Then
Else
WScript.Echo "噢,主目錄創(chuàng)建時出錯!"
End If
If Start = True Then
Err.Clear
Set NewFtpServer = GetObject("IIS://" Computer "/MSFTPSVC/" Index)
NewFtpServer.Start
If Err.Number > 0 Then
WScript.Echo "噢,啟動站點(diǎn)時出錯!"
Err.Clear
Else
End If
End If
ASTCreateFtpSite = Index
End Function
您可能感興趣的文章:- Java語言實(shí)現(xiàn)簡單FTP軟件 輔助功能模塊FTP站點(diǎn)管理實(shí)現(xiàn)(12)
- Windows 2008 IIS7.5中創(chuàng)建獨(dú)立賬號的FTP站點(diǎn)圖文教程
- 使用 Iisftp.vbs 列出FTP站點(diǎn)的方法
- 使用 Iisftp.vbs 暫停FTP站點(diǎn)的方法
- 使用 Iisftp.vbs 停止FTP站點(diǎn)的方法
- 使用 Iisftp.vbs 啟動FTP站點(diǎn)的方法
- 使用 Iisftp.vbs 創(chuàng)建FTP站點(diǎn)的方法
- iis創(chuàng)建用戶隔離模式FTP站點(diǎn)的方法
- 輕松架設(shè)Windows 2003用戶隔離FTP站點(diǎn)的注意事項(xiàng)
- win7下創(chuàng)建個人FTP站點(diǎn)的教程