Prerequisites |
Windows Script Host is built into Microsoft Windows 98, 2000, ME and XP.
If you are running Windows 95 or NT4, you can download Windows Script
Host from the Microsoft Windows Script Technologies Web site at
http://msdn.microsoft.com/scripting/.
Some information is not returned on non-NT-based systems.
A reference set in Projects / References to the
Microsoft WMI Scripting Library. |
|

The Win32_BaseService abstract WMI class
represents executable objects that are installed in a registry
database maintained by the Service Control Manager. The
executable file associated with a service can be started at boot
time by a boot program or by the system. It can also be started
on-demand by the Service Control Manager. Any service or process
that is not owned by a specific user, and that provides an
interface to some functionality supported by the computer
system, is a descendent (or member) of this class. Example: The
dynamic host configuration protocol (DHCP) client service on a
Windows NT/Windows 2000 computer system.
This demo and illustration shows only some of the available
information from the class. For a complete listing see the
Comments section below. Note that some systems may not return
information in all class properties.
|
|
BAS
Module Code |
None. |
|
|
|
Form
Code |
|
To a form add a command button (Command1) and a listbox (List1). Set
a reference in Projects / References to the Microsoft WMI Scripting
Library, and add the following to the form: |
|
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()
Call wmiWin32BaseService
End Sub
Private Sub Form_Load()
Command1.Caption = "Win32_BaseService"
End Sub
Private Sub wmiWin32BaseService()
Dim objset As SWbemObjectSet
Dim obj As SWbemObject
Set objset = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_BaseService")
On Local Error Resume Next
For Each obj In objset
With List1
.AddItem "DisplayName: " & obj.DisplayName
.AddItem "StartName : " & obj.StartName
.AddItem "Description: " & obj.Description
.AddItem "AcceptPause: " & obj.AcceptPause
.AddItem "AcceptStop: " & obj.AcceptStop
.AddItem "DesktopInteract: " & obj.DesktopInteract
.AddItem "ServiceType : " & obj.ServiceType
.AddItem "Started : " & obj.Started
.AddItem "StartMode : " & obj.StartMode
.AddItem ""
End With
Next
End Sub |
|
Comments |
|
All information returned in the Win32_BaseService class (note that
some systems may not return information in all class properties):
boolean |
AcceptPause; |
boolean |
AcceptStop; |
string |
Caption; |
string |
CreationClassName; |
string |
Description; |
boolean |
DesktopInteract; |
string |
DisplayName; |
string |
ErrorControl; |
uint32 |
ExitCode; |
datetime |
InstallDate; |
string |
Name; |
string |
PathName; |
uint32 |
ServiceSpecificExitCode; |
uint8 |
ServiceType; |
boolean |
Started; |
string |
StartMode; |
string |
StartName; |
string |
State; |
string |
Status; |
string |
SystemCreationClassName; |
string |
SystemName; |
uint32 |
TagId; |
|