Posted By

hecUngravity on 08/25/10


Tagged

vbscript


Versions (?)

List computer websites


 / Published in: Visual Basic
 

  1. resultPath = "c:\Scripts\Resultados\Websites.txt"
  2.  
  3.  
  4. set shell = WScript.CreateObject("WScript.Shell")
  5. Set fso = CreateObject("Scripting.FileSystemObject")
  6.  
  7.  
  8. strServer = shell.ExpandEnvironmentStrings("%ComputerName%")
  9. strServerType = "Web"
  10. strServerMetaType = "W3SVC"
  11.  
  12.  
  13. Set destFile = fso.CreateTextFile(resultPath, True)
  14.  
  15.  
  16. SET objService = GetObject( "IIS://" & strServer & "/" & strServerMetaType )
  17. FOR EACH objServer IN objService
  18. IF objServer.Class = "IIs" & strServerType & "Server" THEN
  19.  
  20. destFile.WriteLine("----------------------------------------" & VbCrLf)
  21.  
  22.  
  23. destFile.WriteLine _
  24. "Site ID = " & objServer.Name & VbCrLf & _
  25. "Comment = """ & objServer.ServerComment & """ " & VbCrLf & _
  26. "State = " & State2Desc( objServer.ServerState ) & VbCrLf & _
  27. "LogDir = " & objServer.LogFileDirectory & _
  28. ""
  29.  
  30.  
  31. ' Enumerate the HTTP bindings (ServerBindings) and
  32. ' SSL bindings (SecureBindings) for HTTPS only
  33. strBindings = EnumBindings( objServer.ServerBindings )
  34.  
  35. IF strServerType = "Web" THEN
  36. strBindings = strBindings & _
  37. EnumBindings( objServer.SecureBindings )
  38. END IF
  39.  
  40. destFile.WriteLine("")
  41. IF NOT strBindings = "" THEN
  42. destFile.WriteLine VbTab & "IP Address" & VbTab & "Port" & VbTab & "Host"
  43. destFile.WriteLine strBindings
  44. END IF
  45.  
  46.  
  47. END IF
  48. NEXT
  49.  
  50. destFile.WriteLine("----------------------------------------")
  51.  
  52. destFile.Close
  53.  
  54.  
  55. shell.Run "notepad " & resultPath
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. FUNCTION EnumBindings( objBindingList )
  75. DIM i, strIP, strPort, strHost
  76. DIM reBinding, reMatch, reMatches
  77. SET reBinding = NEW RegExp
  78. reBinding.Pattern = "([^:]*):([^:]*):(.*)"
  79.  
  80. FOR i = LBOUND( objBindingList ) TO UBOUND( objBindingList )
  81. ' objBindingList( i ) is a string looking like IP:Port:Host
  82. SET reMatches = reBinding.Execute( objBindingList( i ) )
  83. FOR EACH reMatch in reMatches
  84. strIP = reMatch.SubMatches( 0 )
  85. strPort = reMatch.SubMatches( 1 )
  86. strHost = reMatch.SubMatches( 2 )
  87.  
  88. ' Do some pretty processing
  89. IF strIP = "" THEN strIP = "All Unassigned"
  90. IF strHost = "" THEN strHost = "*"
  91. IF LEN( strIP ) < 8 THEN strIP = strIP & VbTab
  92.  
  93. EnumBindings = EnumBindings & _
  94. VbTab & _
  95. strIP & VbTab & _
  96. strPort & VbTab & _
  97. strHost & VbTab & _
  98. ""
  99. NEXT
  100.  
  101. EnumBindings = EnumBindings & VbCrLf
  102. NEXT
  103.  
  104. END FUNCTION
  105.  
  106. FUNCTION State2Desc( nState )
  107. SELECT CASE nState
  108. CASE 1
  109. State2Desc = "Starting (MD_SERVER_STATE_STARTING)"
  110. CASE 2
  111. State2Desc = "Started (MD_SERVER_STATE_STARTED)"
  112. CASE 3
  113. State2Desc = "Stopping (MD_SERVER_STATE_STOPPING)"
  114. CASE 4
  115. State2Desc = "Stopped (MD_SERVER_STATE_STOPPED)"
  116. CASE 5
  117. State2Desc = "Pausing (MD_SERVER_STATE_PAUSING)"
  118. CASE 6
  119. State2Desc = "Paused (MD_SERVER_STATE_PAUSED)"
  120. CASE 7
  121. State2Desc = "Continuing (MD_SERVER_STATE_CONTINUING)"
  122. CASE ELSE
  123. State2Desc = "Unknown state"
  124. END SELECT
  125.  
  126. END FUNCTION

Report this snippet  

You need to login to post a comment.