The ASP Emporium
Free Active Server Applications and Examples by Bill Gearhart
Online since Friday January 7, 2000

 home > code > tutorials > Using the <CODE>GetObject()</CODE> function

enter a phrase to search: (advanced search)


 h o m e 

 w h a t 's  n e w 

 a l l   c o d e 
  .net:
    • Fundamentals
    • C# Classes
  classic asp:
    • Code Library
    • ASP Apps
  general:
    • Tutorials
    • SQL

 d o w n l o a d s 

 u s e r   f o r u m s 

 l i n k s 

 s e a r c h 

 s u p p o r t 


Using the GetObject() function

GetObject( ) may very well be the ultimate function of VBScript and JScript, but the Microsoft documentation for the function is so weak that no matter how perceptive you are, you could never guess that it was capable of so much. GetObject( ) is the magic function. It can open almost anything and create an object reference from it. Here's a short list of what you can do with GetObject( ):

  • use a Java Class that has NOT been registered on the server
  • Access and change keys in the IIS Metabase
  • Access and change Windows settings
  • use a Windows Scripting Component that has NOT been registered on the server
  • use a component based on it's CLSID
  • queue a component
  • and on and on...

How can one function be that versatile (and that list above is just a little taste of GetObject( )'s power) and more importantly, how can you specify to GetObject( ) what to do with the object you are referencing?

It's all in the way that the argument of GetObject( ) is specified. Here's a detailed look at the GetObject( ) function:

GetObject([pathname] [, class])

There are two arguments, both of them are optional. Most of the time, you will only use one argument for GetObject( ) and your argument will contain a moniker at it's beginning. Before I lose you on that wierd word moniker, all a moniker is, is a name that represents an object and may include the complete path or address that identifies the location of the object. So a moniker for the GetObject( ) function is usually a one word descriptor representing the type of object being called so that the Scripting Engine can use the proper method to retrieve a working copy of the object that you can use in ASP to perform actions.

These monikers are what allows the GetObject( ) function to be so versatile. Now we need a list of monikers that GetObject( ) supports... This can be a daunting task because the documentation on this stuff is scarse and displaced everywhere and there's nothing stopping you from defining custom monikers that GetObject( ) can use. Here's the ones that I'm familiar with and that GetObject( ) should support on most Windows 2000 and NT machines.

GetObject( ) argument
(including moniker in bold)
what it does
"iis:<metabasepath>" Allows a programmer to view and alter key IIS functionality for any webserver physically connected to this machine.
"java:<classname>" Returns a reference to an unregistered java object found in the %system root%\java\trustlib folder using the Java Virtual Machine.
"script:<absolutepath>" Returns a reference to an unregistered Windows Scripting Component or other supported script type.
"clsid:<clsid>" Returns a reference to an object by it's class ID in the registry.
"WinMgmts:<string>" Allows access to base Windows OS functionality with WMI
"OBJREF:<base64encodedstring>" Returns access to a running object instance
"queue:<clsid/progid>" Used to activate a queued COM+ component via MSMQ.
"new:<clsid/progid>" Allows instancing of any COM component supporting the IClassFactory pointer (including queued components)

Okay that's a pretty good list. There's more but that's all I can think of right now and since you'll probably only use a couple of them, it's really not needed. I just wanted to put up a list because I spent so long trying to find one specific to the GetObject( ) function and came up empty.

So based on all these examples above, a moniker is just a descriptive name that tells GetObject( ) how the object should be referenced without revealing any clues as to how it might internally call and reference the object before an instance is returned to ASP. That way, we can use almost any COM object in ASP and at the same time, not be concerned with the logic that actually gets the object reference. In a nutshell, an ASP programmer will always be able to use the familiar
object.[property][method][collection] [= whatever]
object-oriented interface that their already familiar with, regardless of the type of COM object (based on the Moniker) being called with GetObject( ).

Realistically with ASP, you'll probably only use two of the monikers in the list above with GetObject( ):

"java:<classname>"
"script:<absolutepath>"

The other GetObject( ) monikers are usually used with Windows Scripting Host or in VBA although they can theoretically be used with GetObject( ) in ASP with either VBScript or JScript provided that the proper permissions are enabled, etc...

I'll try to write a little and give an example for each moniker I described above: (Only a few of these will work in ASP. The others require Windows Scripting Host or VBA...)

The java moniker

The java moniker provides a reference to a Java COM object that isn't registered (if you are trying to reference a registered Java object, use CreateObject( ) or ActiveXObject( ) instead). The java COM object being referenced must be in the %WinDir%\java\trustlib directory on the server. I have a couple of code samples that use the java moniker with GetObject( ) here at the ASP Emporium.

Here's a standard call to a Java COM object using GetObject( ) and the java moniker:

Dim oCls
Set oCls = GetObject("java:classname")

Where classname is the name of the class to return an instance of.

You can then call the properties and methods of the class specified in classname.

Click here for a list of ASP Emporium code that uses GetObject( ) with a java moniker.

The IIS moniker

The IIS moniker allows a programmer to access and change settings in the IIS metabase on any server physically attached to your server. The IIS metabase controls all web, ftp and smtp services. This opens the door to all kinds of possibilities as you can configure everything programmatically from ASP (with the proper permissions) or with Windows Scripting Host.

You can get more information about the IIS Metabase and using the IIS moniker with GetObject( ) in these documents:

An Introduction to the IIS Metabase
Using the IIS Metabase to Power ASP
Manipulating the Metabase
Key Names and Paths
ADSI Reference
Working with ADSI - Part I: Understanding the IIsComputer Administration Object
Working with ADSI - Part II: Understanding the IIsWebService and IIsFTPService Administration Objects
Working with ADSI - Part III: Putting It All Together
Automating Administration for IIS 5.0
HOWTO: Configure REMOTE_HOST to Perform a Reverse DNS Lookup in IIS

Here's a couple of examples that you can use with Windows Scripting host to learn how to use the IIS Metabase programmatically with GetObject( ):

To make a WSH file, if you want to write your code in VBScript, name the file with a .VBS extension. If you want to write your code in JScript, name the file with a .JS extension. Since double clicking the file will cause it to run, you need to open the file in a text-editor first before double-clicking it to get it to run.

This first Example is a VBScript Class that recurses through the metabase and returns information about each major section:

' metabase_mapper.vbs

Class IISMetaBase
	Private fso, f, sFilePath

	Public Sub MapMetaBase(byVal filePath)
		sFilePath = filePath
		Set fso = CreateObject("Scripting.FileSystemObject")
		Set f = fso.OpenTextFile(filePath, 8, True)

		GetThisIISPath "IIS://LocalHost", 0

		f.close
		Set f = Nothing
		Set fso = Nothing
	End Sub

	Private Function WriteTab(ByVal tabSize)
		Dim s

		s = ""
		if tabSize > 0 then
			For i = 1 to tabSize
				s = s & vbTab
			Next
		end if

		WriteTab = s
	End Function

	Private Sub GetThisIISPath(byVal ADsPath, byval tabSize)
		Dim oIIS, sItem, i

		Set oIIS = GetObject(ADsPath)

		' Provide a list of all objects installed on this machine
		For Each sItem in oIIS
			With sItem
				f.Write WriteTab(tabSize) & "Name:" & _
					vbtab & vbtab & .Name & vbcrlf
				f.Write WriteTab(tabSize) & "Class:" & _
					vbtab & vbtab & .Class & vbcrlf
				f.Write WriteTab(tabSize) & "ADsPath:" & _
					vbtab & .ADsPath & vbcrlf
				f.Write WriteTab(tabSize) & "GUID:" & _
					vbtab & vbtab & .GUID & vbcrlf
				f.Write WriteTab(tabSize) & "Parent:" & _
					vbtab & vbtab & .Parent & vbcrlf
				f.Write WriteTab(tabSize) & "Schema:" & _
					vbtab & vbtab & .Schema & vbcrlf & vbcrlf

				'recurse any sub nodes...
				GetThisIISPath .ADsPath, tabSize + 1
			End With
		Next

		Set oIIS = Nothing
	End Sub

	Private Sub Class_Terminate()
		MsgBox "IIS Metabase Mapped to " & sFilePath
	End Sub
End Class



Dim oMap

Set oMap = New IISMetaBase
oMap.MapMetaBase "c:\IIS_Setup.txt"
Set oMap = Nothing

To run this, just put it into a vbs file and double click it. A second later, a message box will appear indicating that the IIS Metabase's major parts have been mapped to a text file here: c:\IIS_Setup.txt. On my machine, the text file created by the class looks like this.

Here's another example that returns information about the status of each webserver in IIS: If your running Windows 2000 Professional, you only have 1 webserver so the WSH file should return you something like this:

'W3SVC_Status.vbs

Dim s, t, oIIS, vSite

s = "IIS://LocalHost/W3SVC"
t = ""
Set oIIS = GetObject(s)
For Each vSite in oIIS
	if isnumeric(vSite.Name) then
		t = t & "Site Display Name: " + vSite.ServerComment & vbcrlf
		t = t & "Site Metabase Index: " & s & "/" & vSite.Name & vbcrlf
		t = t & "Site Server State:"
		Select case vSite.ServerState
			case &H00000002
				t = t & " (Server Running)"
			case &H00000004
				t = t & " (Server Stopped)"
			case &H00000006
				t = t & " (Server Paused)"
			case else
				t = t & " (Server State Unknown) "
				t = t & vSite.ServerState
		end Select
		t = t & vbcrlf & vbcrlf
	end if
Next
Set oIIS = Nothing

WScript.Echo t

The IIS moniker is super powerful. Administration of IIS can be controlled programmatically to automate certain tasks that are repetitive, boring or difficult...

The script moniker

The script moniker is like the Golden Ticket in a Wonka Bar: It allows you to access any unregistered windows scripting component on your server! That means that you can write a Windows Scripting COM object, place it in your cgi-bin or anywhere else on your web site and run it, effectively bypassing your annoying host that doesn't want to register your COM object. Now you can encapulate your most useful code into a Windows Scripting Component and it's available from any ASP page, avoiding unnecessary code duplication.

Windows scripting components are created using XML and a scripting language like VBScript, JScript or PerlScript. You don't need to know the actual logic of the XML used if you use the Scripting Component wizard... 4guysfromrolla.com has a good set of tutorials and links for windows scripting component development:

View the 4 guys WSC tutorials here

Here's a standard call to a WSC COM object using GetObject( ) and the script moniker:

Dim oCls
Set oCls = GetObject("script:path")

Where path is the fully qualified path to the WSC to return an instance of.

You can then call the properties and methods of the class specified in path.

I thought a good tester for the GetObject( ) function with a script moniker would be a simple Windows Script Component that writes to the Windows NT Event Log from ASP! I can think of 1,000,000 uses for a component like this and it's ridiculously easy to do. WSC provides a good middle-ground where an ASP programmer can use WScript objects (like Shell...) that normally aren't available in an ASP page. This effectively allows you to have access to many more objects than ASP usually provides... (Of course your host will need to be running Windows Script 5.5 which is installed with VBScript 5.5).

Okay, if you're using Windows NT or 2000, you have an event log that most apps and services write into to let you know what's happening with them as they operate. Usually when something craps out on your box, you go to the event log to see if the app logged an error... why not do the same with your ASP files.

If you're running your own server, you have no reason not to be logging ASP errors to the NT event log. If you're using a host, writing to their server's event log is probably the best way to piss them off in a hurry (and will do you no good as you can't get to the logs to view them).

Here's what it looks like when the Windows Scripting Component that I wrote logs to the Event Log from an ASP file:

If you clicked on one of those NT Application Log entries, you would get a screen like this:

You can log anything you want to but the greatest potential lies most likely in reporting errors within your ASP apps.

Download the WSC "EventLogger" COM object (documentation for the object is embedded in the WSC file which you can open with notepad), installation instructions and a sample ASP page that calls the EventLogger WSC using GetObject( ) and prints 5 lines to your NT Application Event Log.

Download

http://downloads.aspemporium.com/wsc_eventlogger.zip

Here's the source for both the WSC com object and the ASP file that calls it:

EventLogger.WSC
<?xml version="1.0"?>
<component>

<comment>
<![CDATA[ 


EventLogger.WSC COM Object (Windows Scripting Component)
http://www.aspemporium.com/aspEmporium/index.asp
Last Updated: 2/28/2001
Version: 1.0


------------------------------
 Purpose:
------------------------------
  writes a line to the Windows NT or 2000 Event Log
  (in the "Application Log" section) on the Server.


------------------------------
 Properties:
------------------------------
  WSCError
    Returns an error message as a string. Will return empty string "" if
    no error is encountered when writing to the event log. Will only
    contain valid data after the LogAnEvent( ) method is called.
    Test for COM errors like this:
       if object.WSCError <> "" Then Response.Write(object.WSCError)


  EventLogger_Version
    Returns a string indicating the "major.minor" version info for this
    WSC COM object.


------------------------------
 Methods:
------------------------------
  LogAnEvent( <[Integer] LogType>, <[String] LogDescription> )
    Returns void. Writes an event to the Windows 2000 or NT application log.
       - LogType argument
            Integer representing one of the LogType constants below.
            Indicates the type of event that will be entered
            into the log.
       - LogDescription argument
            String representing the description to log in the NT
            event logs.


------------------------------
 Syntax/Usage:
------------------------------
  Dim oLog
  Set oLog = GetObject("script:" & Server.Mappath("<virtual path>") & ))
  oLog.LogAnEvent <Integer LogType>, <String LogDescription>
  If oLog.WSCError <> "" Then 
    Response.Write("An error Occurred: " & oLog.WSCError)
  End If
  Set oLog = Nothing


------------------------------
 LogType Constants: 
------------------------------
   You must declare these constants in any page controlling
   this object (they are not publicly exported even if the
   object's type library is referenced.) It is acceptable 
   to use the constant's value in place of it's name.
+---------------------+----------+-------------------------------------------+
|   CONSTANT NAME     |  VALUE   |                DESCRIPTION                |
+---------------------+----------+-------------------------------------------+
| NTLog_Error         |    1     | This event is describing an error         |
+---------------------+----------+-------------------------------------------+
| NTLog_Warning       |    2     | This event is describing a warning        |
+---------------------+----------+-------------------------------------------+
| NTLog_Information   |    4     | This event is describing some information |
+---------------------+----------+-------------------------------------------+
| NTLog_Audit_Success |    8     | This event is describing an Audit Success |
+---------------------+----------+-------------------------------------------+
| NTLog_Audit_Failure |    16    | This event is describing an Audit Failure |
+---------------------+----------+-------------------------------------------+


------------------------------
 Requirements:
------------------------------
 - VBScript 5.5 Scripting Engine or better (created and tested on 5.6 beta)
 - Windows NT or 2000 with IIS 4 or 5 (created and tested on IIS 5)
   Works with Windows 9x but since there is no Event Log on those machines,
   the log will write to a file in the Windows directory called: WSH.log
 - Windows Scripting Host and Windows Script must be installed on the server
   (usually installed with the latest VBScript Scripting Engine download from 
   Microsoft and automatically installed with Windows 2000.)
 - ASP 2.0 or 3.0 (created and tested on 3.0)


]]> 
</comment>



<registration
	description="EventLogger"
	progid="EventLogger.WSC"
	version="1.00"
	classid="{285910f7-aafc-4280-9295-78ec03eaa714}"
>
</registration>

<public>
	<property name="WSCError" get="get_WSCError" />
	<property name="EventLogger_Version" get="get_NTLog_Version" />
	<method name="LogAnEvent" />
	<event name="OnEventLogged" />
	<event name="OnEventNotLogged" />
</public>

<script language="VBScript">
<![CDATA[



Option Explicit

Dim WSCError, sIntVers

sIntVers = "1.0"
WSCError = ""

Function get_NTLog_Version()
	get_NTLog_Version = sIntVers
End Function

Function get_WSCError()
	get_WSCError = WSCError
End Function

Sub LogAnEvent(ByVal LogType, ByVal LogMessage)
	Dim wshShell

	On Error Resume Next

	Set WshShell = CreateObject("WScript.Shell")
	WshShell.LogEvent LogType, LogMessage
	Set wshShell = Nothing

	If Err Then 
		WSCError = Err.Description
		fireEvent("OnEventNotLogged")
	Else
		fireEvent("OnEventLogged")
	End If
End Sub



]]>
</script>

</component>

EventLogger_caller.asp
<% @ Language = VBScript %>
<%
Option Explicit
With Response
	.Buffer = True
	.Expires = 0
	.Clear
End With


Public Const NTLog_Error          = 1
Public Const NTLog_Warning        = 2
Public Const NTLog_Information    = 4
Public Const NTLog_Audit_Success  = 8
Public Const NTLog_Audit_Failure  = 16


Dim oLogger

 'Use this line if you are not going to 
 'register the WSC COM object, and put 
 'the WSC file in the root of your site:
Set oLogger = GetObject("script:" & Server.Mappath("/EventLogger.wsc"))

 'If you register the WSC COM object use 
 'this next line instead:
'  Set oLogger = CreateObject("EventLogger.wsc")

With oLogger

	 ' add an error to the NT application event logs 
	.LogAnEvent NTLog_Error, "EventLogger.WSC Logged an Error"

	 ' add a warning to the NT application event logs 
	.LogAnEvent NTLog_Warning, "EventLogger.WSC Logged a Warning"

	 ' add information to the NT application event logs 
	.LogAnEvent NTLog_Information, "EventLogger.WSC Logged Some Information"

	 ' add audit success to the NT application event logs 
	.LogAnEvent NTLog_Audit_Success, "EventLogger.WSC Logged Audit Success"

	 ' add audit failure to the NT application event logs 
	.LogAnEvent NTLog_Audit_Failure, "EventLogger.WSC Logged Audit Failure"


	 'check for an error and if one was returned, display it...
	If .WSCError <> "" Then 
		Response.Write("An error Occurred " & _
			"In The COM Object: " & _
			.WSCError)
	Else
		Response.Write("Open the NT Application Event log " & _
			"using the Event Viewer to see if the WSC worked.")
	End If
End With

 'clean up
Set oLogger = Nothing
%>

The WinMgmts moniker

The WinMgmts moniker is used to automate various Windows tasks using something called Windows Management Instrumentation or WMI for short. Rather than write a bunch of boring stuff about WMI, I'll just create a couple of examples that give a peek at what you can do with it... The first example returns a little bit of information about the computer that the script is running on. The second example returns detailed information about NTFS directories and shows a simple example of how to query WMI objects using a language similar to SQL rather than looping through collections.

Here's a simple script for WSH that will tell you something about the computer you're currently running the script on. It produces output similar to this:

Here's the code that produces that output:

'winmgmts1.vbs

function TranslateDomainRole(byVal roleID)
	Dim a

	Select Case roleID
		Case 0
			a = "Standalone Workstation"
		Case 1
			a = "Member Workstation"
		Case 2
			a = "Standalone Server"
		Case 3
			a = "Member Server"
		Case 4
			a = "Backup Domain Controller"
		Case 5
			a = "Primary Domain Controller"
	End Select
	TranslateDomainRole = a
end function

Dim s, System, item
Set System = GetObject("winmgmts:").instancesOf("Win32_ComputerSystem")
for each item in system
	s = "Computer Info" & vbcrlf
	s = s & "***********************" & vbcrlf
	s = s & "Name: " & item.name & vbcrlf
	s = s & "Status: " & item.status & vbcrlf
	s = s & "Type: " & item.SystemType & vbcrlf
	s = s & "Mfg: " & item.Manufacturer & vbcrlf
	s = s & "Model: " & item.Model & vbcrlf
	s = s & "RAM: ~" & item.TotalPhysicalMemory\1024000 & "mb" & vbcrlf
	s = s & "Domain: " & item.Domain & vbcrlf
	s = s & "Role: " & TranslateDomainRole(item.DomainRole) & vbcrlf
	s = s & "Current User: " & item.UserName & vbcrlf
	wscript.echo s
next


The next example is a pretty-cool tool. It allows a user to enter one or more directory paths and get back some info about the entered directories. WMI has an SQL type of query syntax that you can use to return info about specific entries in a collection. This example shows how to dynamically create an SQL string based on entered directory paths.

When you first run the app, an input box like this one appears where you can enter some directories to get:

After you hit OK, the app will show you the WMI SQL that it created based on the directories that you entered in the inputbox. Notice how the \ character is escaped in the SQL statement...

The system will return one message box for each directory that you enter...


Here's the code that does it:

'DirInfo.vbs

Class DirInfo
   Public Sub Execute()
      Dim s, System, item, wmiSQL, y, perm
      Dim iBox, vDirs, i, wmiSQLFrag

      wmiSQLFrag = ""
      ' allow a user to enter some input
      iBox = InputBox("Enter a string of directories to " & _
         "return info about, separated by commas." & _
         vbcrlf & "For example: d:\WINNT, d:\Program Files")

      if len(iBox) = 0 then exit sub

      vDirs = split(iBox, ",")
      for i = 0 to ubound(vDirs)
         'escape any \ characters
         vDirs(i) = Trim(Replace(vDirs(i), "\", "\\"))
         'create sql fragment
         wmiSQLFrag = wmiSQLFrag & "Name='" & vDirs(i) & "' Or "
      next
      if len(wmiSQLFrag) > 3 then wmiSQLFrag = _
         Left(wmiSQLFrag, len(wmiSQLFrag) - 4)

      'final SQL statement
      wmiSQL = "SELECT * FROM Win32_Directory WHERE " & wmiSQLFrag

      'show the SQL to the user
      wscript.echo wmiSQL

      'execute the query
      Set System = GetObject("winmgmts:").ExecQuery(wmiSQL)

      'loop through each directory and return some info
      for each item in system
         s = ""
         s = s & "Name: " & item.name & vbcrlf

         s = s & "Created On: " & _
         MakeReadableDate(item.CreationDate) & vbcrlf
         s = s & "Last Accessed: " & _
         MakeReadableDate(item.LastAccessed) & vbcrlf
         s = s & "File System: " & item.FSName & vbcrlf
         if item.FSName = "NTFS" Then
            s = s & "Permissions:" & vbcrlf
            s = s & _
            DeterminePermissions(item.AccessMask) & vbcrlf
         end if
         s = s & "Status: " & item.Status & vbcrlf

         'show the directory's info to the user
         wscript.echo s
      next
   End Sub

   ' a lot of these win32 objects return streams of data that make them
   ' annoying to just casually browse when trying to lookup so the two
   ' functions below turn date streams and permission streams (in their
   ' raw forms, they are integers) into readable text.

   Private Function MakeReadableDate(byVal dateIn)
      dim re, m, dateitem, d, item, yr, mth, da, i

      set re = New RegExp
      re.pattern = "^(\d{4})(\d{2})(\d{2})"
      re.global = false
      re.multiline = false
      Set m = re.execute(dateIn)
      for each dateitem in m
         set d = dateitem.submatches
         i = 0
         for each item in d
            select case i
               case 0: yr = item
               case 1: mth = item
               case 2: da = item
            end select
            i = i + 1
         next
      next
   
      MakeReadableDate = mth & "/" & da & "/" & yr
   End Function

   Private Function DeterminePermissions(byVal permIn)
      dim re, m, sm, out, sRem, i

      out = ""
      set re = new regexp
      re.pattern = "(20|19|18|17|16)"
      re.global = true
      if re.test(permIn) then
         set m = re.execute(permIn)
         for each sm in m
            select case sm
               case 16
                  out = out & _
                  vbTab & "Delete" & vbcrlf
               case 17
                  out = out & _
                  vbTab & "Read Control" & vbcrlf
               case 18
                  out = out & _
                  vbTab & "Write DAC" & vbcrlf
               case 19
                  out = out & _
                  vbTab & "Write Owner" & vbcrlf
               case 20
                  out = out & vbTab & _
                  "Synchronize" & vbcrlf
            end select
         next
         set m = nothing
         sRem = re.replace(permIn, "")
         for i = 1 to len(sRem)
            select case mid(sRem, i, 1)
               case 0
                  out = out & vbtab & _
                  "FILE_READ_DATA (file) or " & _
                  "FILE_LIST_DIRECTORY " & _
                  "(directory)" & vbcrlf
               case 1
                  out = out & vbtab & _
                  "FILE_WRITE_DATA (file) or " & _
                  "FILE_ADD_FILE " & _
                  "(directory)" & vbcrlf
               case 2
                  out = out & vbtab & _
                  "FILE_APPEND_DATA (file) or " & _
                  "FILE_ADD_SUBDIRECTORY " & _
                  "(directory)" & vbcrlf
               case 3
                  out = out & vbtab & _
                  "FILE_READ_EA" & vbcrlf
               case 4
                  out = out & vbtab & _
                  "FILE_WRITE_EA" & vbcrlf
               case 5
                  out = out & vbtab & _
                  "FILE_EXECUTE (file) or " & _
                  "FILE_TRAVERSE " & _
                  "(directory)" & vbcrlf
               case 6
                  out = out & vbtab & _
                  "FILE_DELETE_CHILD " & _
                  "(directory)" & vbcrlf
               case 7
                  out = out & vbtab & _
                  "FILE_READ_ATTRIBUTES" & vbcrlf
               case 8
                  out = out & vbtab & _
                  "FILE_WRITE_ATTRIBUTES" & vbcrlf
            end select
         next
      end if
      if len(out) > 1 then out = left(out, len(out) - 2)
      DeterminePermissions = out
   End Function
End Class



Dim a 

Set a = New DirInfo
a.Execute
Set a = Nothing

It's basically just a simple VBScript class with 1 method but nonetheless is still a good example of how to work with the WinMgmts moniker and VBScript's GetObject( ) function.

The best place to find detailed information on WMI is from Microsoft. Here's a collection of some good WMI links for more information:

Operating System Classes
Win32 Classes
Managing Windows with WMI
Managing Windows with WMI (examples)
Windows Management Instrumentation Scripting
Take Charge with Windows Management Instrumentation
Windows 2000: Script Heaven
Microsoft Windows Management Instrumentation Scripting
Windows Management Instrumentation Scripting
Using the WMI Scripting Type Library with Windows Scripting Host 2.0
Retrieving a WMI Class Instance
Windows Management Instrumentation: A Simple, Powerful Tool for Scripting Windows Management
ADSI GetObject Queries May Fail from ASP but Work from VBScript
random WMI examples
random WMI examples
random WMI examples
random WMI examples

Various other monikers

There's a ton of other monikers that GetObject() supports. Here's some links to other monikers:

QUEUE and NEW monikers:

Developing Queued Components
HOWTO: Invoke Queued Components from ASP
HOWTO: Configure a COM+ Application for Queued Components
Queued Components Architecture
Using the New Moniker to Activate Queued Components
Using the Queue Moniker to Activate Queued Components

CLSID and OBJREF monikers:

Interface and Implementation Again
DCOM Architecture
OBJREF Moniker Implementation

Links related to GETOBJECT() in general:

HOWTO: Optimize OLE Server Instance Usage by Using GetObject
FIX: VBScript GetObject() Fails to Return Rich Error Information
Microsoft Knowledge Base Info for using GetObject with ASP