国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 編程設計 > 正文

如何編寫一個創建FTP站點的函數?

2020-06-19 13:52:32
字體:
來源:轉載
供稿:網友

如何編寫一個創建FTP站點的函數?

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 & "程序將退出!"
            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 & "取消創建本站點."
                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 "
,創建站點異常!正在創建的站點的序號為:"&Index&"." & VbCrlf & "取消創建本站點."
                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 "
,主目錄創建時出錯!"
        End If

        If Start = True Then
            Err.Clear
            Set NewFtpServer = GetObject("IIS://" & Computer & "/MSFTPSVC/" & Index)
            NewFtpServer.Start
            If Err.Number <> 0 Then
                WScript.Echo "
,啟動站點時出錯!"
                Err.Clear
            Else
            End If
        End If    
        ASTCreateFtpSite = Index
End Function

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 方正县| 文昌市| 贺州市| 南乐县| 页游| 涞源县| 穆棱市| 勐海县| 惠来县| 天水市| 佛山市| 邯郸市| 大同市| 泸溪县| 赣州市| 宜阳县| 张家口市| 嘉兴市| 凤阳县| 和顺县| 栾川县| 桃园县| 南岸区| 乌拉特后旗| 宁陕县| 视频| 大埔县| 疏附县| 山阴县| 平遥县| 出国| 措美县| 贵南县| 新竹市| 阿瓦提县| 青神县| 农安县| 理塘县| 文昌市| 巩留县| 信丰县|