:Start of Svcslst Svcslst.dsc
DragonSphereSoftware

DragonSphere Software Demos


If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.





#
# DragonSphere Software's Home Page
#  
# All Source Files for this demo
#
# This is an example of using WMI to place the list of services and their states
# in an MS Excel spreadsheet
#

Title Service List
If @Greater(@Name(@SYSINFO(DSVER)),4)

External GadgetX.dll,@SYSINFO(DSVER)

  # GadgetX Commands
  #DEFINE COMMAND,GadgetX,DEFINE,OLE,Set
  # GadgetX Functions
  #DEFINE FUNCTION,GadgetX,OLE,Get
Else
  Warn This Example uses VDS 5 or above syntax.
  Stop
End

Define variable,Object,objExcel
Define variable,Object,objWMIService
Define variable,Object,objServices
Define variable,Object,objService
Define variable,Collection,colServices

Ole Init

%x = 1
Set objWMIService,@Ole(GetObject,NULL,"WinMgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objServices,@Ole(Call,objWMIService,^o,"ExecQuery(^B)",Select * From Win32_Service)


Set colServices,@Ole(BeginCollection,objServices)
Set objExcel,@Ole(Create,"Excel.Application",NULL)
Ole Set,objExcel,"Visible = ^B",True
Ole Call,objExcel,Workbooks.Add

While @Ole(Next,objService,From,colServices)
    %%Test =  @Ole(Get,objService,"^B",Name)
    Ole Set,objExcel,"Cells(^d,^d) = ^B",%x,1,%%Test
    Ole Set,objExcel,"Cells(^d,^d) = ^B",%x,2,@Ole(Get,objService,"^B",State)
    %x = @succ(%x)
Wend
Info "Wait to close"

Ole Call,objExcel,Quit

Ole Free,Object,objExcel

Ole Free,Collection,colServices
Ole Free,Object,objServices
Ole Free,Object,objWMIService

Ole UnInit
Exit
:End of Svcslst