Dim oService
Dim oServiceProperty
Dim fs
Dim rsService
Dim LastServerName
Dim LastServerIP
Dim logPaths(1000)
Dim DEFAULTAPPPATH, DEFAULTLOGPATH, DEFAULTLOCALAPPPATH
Dim REGSECTION, REGINSTALLPATH

   DEFAULTAPPPATH = "\C$\Program Files"
   DEFAULTLOCALAPPPATH = "C:\Program Files"
   DEFAULTLOGPATH = "\WebHost Automation\Helm\System"
   REGSECTION = "SOFTWARE\Microsoft\Windows\CurrentVersion"
   REGINSTALLPATH = "ProgramFilesDir"
	
   Set oService = Wscript.CreateObject("HELM.CService")
   Set oServiceProperty = Wscript.CreateObject("HELM.CServiceProperty")
   Set fs = Wscript.CreateObject("Scripting.FileSystemObject")
   Set rsService = oService.SearchEx	

   Wscript.Echo rsService.RecordCount & " total services"	
   rsService.Filter = "(InterfaceId=6 OR InterfaceId=26 OR InterfaceId=19 OR InterfaceId=20)"
   rsService.Sort = "ServerNetBiosName"
   Wscript.Echo rsService.RecordCount & " web services to check"

   Do While Not rsService.EOF
        If Not LastServerName = rsService.Fields("ServerNetbiosName") Then
            For i = LBound(logPaths) To UBound(logPaths)
                logPaths(i) = ""
            Next 
            LastServerName = rsService.Fields("ServerNetbiosName")
            LastServerIP = Trim(rsService.Fields("ServerIPAddress"))
            Wscript.Echo "Connecting to '" & LastServerName & "' (" & LastServerIP & ")"
            Wscript.Echo "Checking Default Log Folder"

            LogPath = "\\" & LastServerIP & DEFAULTAPPPATH & DEFAULTLOGPATH
            LocalLogPath = DEFAULTLOCALAPPPATH & DEFAULTLOGPATH
            If Not fs.FolderExists(LogPath) Then
                Wscript.Echo "Checking Default Log Folder - Failed"
                Wscript.Echo "Getting Log Folder From Registry"                                

		Wscript.Echo "WOULD NORMALLY READ THE REGISTRY HERE"
                
                LocalLogPath = LogPath & DEFAULTLOGPATH
                LogPath = PathToUNC(LastServerIP, LogPath)
                If Not fs.FolderExists(LogPath) Then
                    Wscript.Echo "UNABLE TO CONNECT TO REMOTE LOG FOLDER!"
                End If
                LogPath = LogPath & DEFAULTLOGPATH
         
		Wscript.Echo "WOULD NORMALLY CREATE THE LOG PATH HERE IF NOT FOUND"
	    End If
		
            Wscript.Echo"  Collection Logs..."
            Set LogFolder = fs.GetFolder(LogPath)
            For Each LogFile In LogFolder.Files
                If Left(LogFile.Name, 2) = "hb" And Right(LogFile.Name, 4) = ".xml" Then
                    Wscript.Echo ">> " & LogFile.Name                    
		    Wscript.Echo "WOULD NORMALLY LOAD THE XML INTO THE ADO RECORDSET HERE"
                End If
            Next
        End If
        
        LogPath = LCase(oServiceProperty.SearchValueEx(CLng(rsService.Fields("ServiceID")), "RootWebDirectory"))
        diffLogPath = True
        For i = LBound(logPaths) To UBound(logPaths)
            If Len(logPaths(i)) = 0 Then Exit For
            If logPaths(i) = LogPath Then
                diffLogPath = False
                Exit For
            End If
        Next
        If diffLogPath Then
            logPaths(i) = LogPath
	    Wscript.Echo "WOULD NORMALLY LAUNCH THE BANDWIDTH ANALYSER ON THE SERVER HERE"	            
        Else
            Wscript.Echo "Bandwidth Analyser Launch Not Required"
        End If
        rsService.MoveNext
   Loop

   Set rsService = Nothing
   Set oService = Nothing
   Set oServiceProperty = Nothing
   Set fs = Nothing
