VBScript: Shortcuts for IIS Log Directories

I love parsing through IIS logfiles but I dislike the directory structure that Microsoft creates for IIS logging. Each site has a randomly generated directory name so, for example, "netnerds.net" could store its files in "C:\windows\system32\logfiles\W3SVC720199813." Who wants to track that down? Not me! Use the script below to change your ugly directory names into something that's human readable.

[Note: A screenshot previously embedded here showed the generated Shortcuts folder containing .lnk files pointing to each site's IIS log directory. The original image asset is no longer available and has been removed.]

 1'************************************************************
 2' This script created by Chrissy LeMaire ([email protected])
 3' Website: https://netnerds.net/
 4'
 5' NO WARRANTIES, etc.
 6'
 7' This script creates human-readable shortcuts to your
 8' IIS logging directories.
 9'
10' Requirements -- ability to read IIS:// and permissions to
11' create subdirectories and files in your logging directory. If you encounter
12' any problems, it's probably because you don't have proper permissions.
13'
14' This script was tested on Windows Server 2003 (IIS 6).
15'
16' "What it does"
17' 1. Reads the master log file path (usually C:\\windows\\system32\\logfiles)
18' 2. Creates a directory called Shortcuts in the master log file path
19' 3. Creates shortcuts to each directory using the website name
20'    listed in the IIS websites tree. Done!
21'************************************************************
22
23Set objW3SVC = GetObject("IIS://localhost/W3SVC")
24MasterLogFilePath = objW3svc.LogFileDirectory
25shortcutDir = MasterLogFilePath & "\\Shortcuts"
26
27Set fso = CreateObject("Scripting.FileSystemObject")
28If fso.FolderExists(shortcutDir) = FALSE Then
29    fso.CreateFolder(shortcutDir)
30Else
31    ' empty it out.. keep it clean. so you can run this every few months
32    fso.DeleteFolder(shortcutDir)
33    fso.CreateFolder(shortcutDir)
34End If
35Set fso = Nothing
36
37For Each objSITE In objW3SVC
38    If objSITE.Class = "IIsWebServer" Then
39        websiteName = objSITE.ServerComment
40        w3LogFilePath = objSITE.LogFileDirectory & "\\w3svc" & objSITE.Name
41
42        ' If logging is enabled and the website is running.
43        If objSITE.LogType > 0 And objSITE.ServerState <> 4 Then
44            Set WshShell = CreateObject("WScript.Shell")
45            Set oShellLink = WshShell.CreateShortcut(shortcutDir & "\\" & websiteName & ".lnk")
46            oShellLink.TargetPath = w3LogFilePath
47            oShellLink.IconLocation = "explorer.exe, 13"
48            oShellLink.Description = "Shortcut Script"
49            oShellLink.Save
50            Set oShellLink = Nothing
51            Set WshShell = Nothing
52
53            siteList = siteList & websiteName & " = " & w3LogFilePath & vbCrLf
54        End If
55    End If
56Next
57
58MsgBox siteList ' or not