ObjectManager Class
File Class: ObjectManager.class
Include Clause: INCLUDE "ObjectManager.class"
Classes Including:
Include ----->None
Remark:
This class automatically creates objects of type Shell, FileSystemObject, Network and WMI (Windows Management Instrumentation), simulates the behavior of a Shared Class C # and therefore does not need to instantiate an object class, is activated through use of a INCLUDE.
Sintax:
None.
Methods:
SetWmiNameSpace
Parameters --> Name(Data Type): Description
NameSpace (String) : A valid Windows Management Instrumentation (WMI) Namespace
Return Value: None.
Change the Namespace to act on the property wmi. The initial value is "root\cimv2".
Properties:
Fso
Data type: Object
Access type: Read-Only
Return a reference to an object of type 'Scripting.FileSystemObject'.
Shell
Data type: Object
Access type: Read-Only
Return a reference to an object of type "WScript.Shell".
Net
Data type: Object
Access type: Read-Only
Return a reference to an object of type "WScript.Network".
Wmi
Data type: Object
Access type: Read-Only
Return a reference to an object of type "winmgmts:\\" in local computer.
Example:
INCLUDE "ObjectManager.class"
'Calling to WScript.Network Property
WScript.Echo ObjectManager.Net.ComputerName
'Calling to Scripting.FileSystemObject Method.
WScript.Echo ObjectManager.Fso.GetFile("ObjectManager.class").Path
'Calling to WScript.Shell Property
WScript.Echo ObjectManager.Shell.CurrentDirectory
'Calling to WMI (Windows Management Instrumentation) Method
Dim So
For Each So in ObjectManager.Wmi.ExecQuery("Select * from Win32_OperatingSystem")
WScript.Echo "Operating System: " & So.Caption
WScript.Echo "Version: " & So.Version
WScript.Echo "Service Pack: " & So.CSDVersion
Next
'Changing WMI (Windows Management Instrumentation) NameSpace to "StdRegProv"
ObjectManager.SetWmiNameSpace("root\default:StdRegProv")
const HKEY_LOCAL_MACHINE = &H80000002
Dim arrSubKeys,strSubKey
ObjectManager.Wmi.EnumKey HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services", arrSubKeys
For Each strsubkey In arrSubKeys
wscript.Echo strSubkey
Next
See Also:
Another way to use Shell, FileSystemObject and other objects in WSH/vbcript