0

I am looking for a way to find the log folder path of a certain website in IIS by its ID name, like: W3SVC1 or any other method, from inside my application. Is this possible? I tried looking up and down google and found nothing. How is this achieved?

The following code works, but only gets all of the application names/ids (like W3SVC/1), i need the actual log file path, and since they can change I don't want to use the static default log file directory as the root on this:

 Function ProcessWebSite(ServiceType, SiteNumber) Set IISWebSite = getObject("IIS://localhost/" & ServiceType & "/" & SiteNumber) Set IISWebSiteRoot = getObject("IIS://localhost/" & ServiceType & "/" & SiteNumber & "/root") ProcessWebSite = IISWebSite.ServerComment Set IISWebSiteRoot = nothing Set IISWebSite = Nothing end function Function ShowSites(ServiceType, ClassName, Title) Response.write "Web Sites Description=" & "<br>" Response.write "===============================================================" & "<br>" Set IISOBJ = getObject("IIS://localhost/" & ServiceType) for each Web in IISOBJ if (Web.Class = ClassName) then Response.write Ucase(ServiceType) & "/" & Web.Name & _ Space(17-(len(Ucase(ServiceType))+1+len(Web.Name))) & " " & _ ProcessWebSite(ServiceType, Web.name) & "<br>" end if next Set IISOBj=Nothing End function Call ShowSites("w3svc", "IIsWebServer", "Web") 

1 Answer 1

1
Function Returnlog(WebSitePath) Dim statut Set IISOBJRoot = getObject(webSitePath) Returnlog = IISOBJRoot.LogFileDirectory set IISOBJRoot = Nothing end Function IIsObjectPath = "IIS://localhost/w3svc" Set IIsObject = GetObject(IIsObjectPath) for each obj in IISObject if (Obj.Class = "IIsWebServer") then BindingPath = IIsObjectPath & "/" & Obj.Name Set IIsObjectIP = GetObject(BindingPath) WScript.Echo IISObjectIP.ServerComment & ": " & Returnlog(IISObjectIP.ADSPath) & vbnewline 'WScript.Echo IISObjectIP.LogType & vbnewline end if next 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.