code_junkie

How do I programmatically (in vbscript) change/set the tcp port for a site under IIS?

Nov 12th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. C:InetpubAdminScripts
  2.  
  3. Dim objWebApp
  4. Dim intArraySize
  5. Dim arrOldBindings
  6. Dim arrNewBindings
  7.  
  8. Set objWebApp = GetObject("IIS://localhost/w3svc/" WebSiteID)
  9.  
  10. If isArray(objWebApp.ServerBindings) then
  11.  
  12. arrOldBindings = objWebApp.ServerBindings
  13. intArraySize = UBound(arrOldBindings)
  14. Redim arrNewBindings(intArraySize + 1)
  15.  
  16. For i = 0 to intArraySize
  17. arrNewBindings(i) = arrOldBindings(i)
  18. Next
  19.  
  20. arrNewBindings(intArraySize + 1) = ":mydomain.com:8080:"
  21.  
  22. objWebApp.Put "ServerBindings", (arrNewBindings)
  23. objWebApp.SetInfo
  24.  
  25. End If
  26.  
  27. Set objWebApp = GetObject("IIS://localhost/w3svc/" WebSiteID)
  28.  
  29. If isArray(objWebApp.ServerBindings) then
  30.  
  31. arrOldBindings = objWebApp.ServerBindings
  32. intArraySize = UBound(arrOldBindings)
  33. Redim arrNewBindings(intArraySize + 1)
  34.  
  35. For i = 0 to intArraySize
  36. arrNewBindings(i) = arrOldBindings(i)
  37. Next
  38.  
  39. arrNewBindings(intArraySize + 1) = ":mydomain.com:8080:"
  40.  
  41. objWebApp.Put "ServerBindings", (arrNewBindings)
  42. objWebApp.SetInfo
  43.  
  44. End If
Add Comment
Please, Sign In to add comment