:Start of Svcslst <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN"> <html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Svcslst.dsc</title><STYLE>BODY{FONT-SIZE: 12px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #ffffed } A{COLOR: Blue} A:active {FONT-WEIGHT: bold; COLOR: #008000} A:visited{FONT-WEIGHT: bold; COLOR: #400000} A:hover{ FONT-WEIGHT: bold; COLOR: #008000;} H1{COLOR: #400000; TEXT-ALIGN: left FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif} #copyright { border-top: 2px solid rgb(165, 82, 0); width: 100%; } DIV.left{TEXT-ALIGN: left} DIV.centered{TEXT-ALIGN: center}</STYLE></head><body bgcolor=#ffffed><table width="100%" height="133"><tr height="129"><th width="173"><a href = "http://www.dragonsphere.net" target = "_blank"><img style="Z-INDEX: 100; LEFT: 25px; POSITION: absolute; TOP: 40px" height="124" alt="DragonSphere" src="http://www.dragonsphere.net/images/dragonfly.png" width="169" align="left" border="0"></a></th><th><a href = "http://www.dragonsphere.net" target = "_blank"><img style="Z-INDEX: 100; LEFT: 200px; POSITION: absolute; TOP: 40px" height="124" alt="Software" src="http://www.dragonsphere.net/images/dslogotext.png" width="473" align="left" border="0"></a></th></tr></table><br/><!--

#DEFINE COMMAND,<!--
#DEFINE COMMAND,-->
<!-- This is crazy but now we should be able to see this script in the browser and run it in VDS too without changing the source code. --><h1>DragonSphere Software Demos</h1><br/><p>If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.</p><br/><hr><br/><pre><CODE>
#
# <a href = "http://www.dragonsphere.net" target = "_blank">DragonSphere Software's Home Page</a>
#  
# <a href = "http://www.dragonsphere.net/products/gadgetx/demos/Svcslst.zip">All Source Files for this demo</a>
#
# 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)
<!-- GadgetX --><a href = "http://www.dragonsphere.net/products/gadgetx/gadgetx.zip">
External GadgetX.dll,@SYSINFO(DSVER)
<!-- GadgetX --></a>
  # 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
<!-- This is crazy but now we should be able to see this script in the browser. --></CODE></pre><div id="copyright"><p>copyright &copy; DragonSphere Software 2000-2006<br><a href="http://www.dragonsphere.net/terms.html" target="_blank">Terms and Conditions</a></p></div></body></html><!--
:-->
:<!--
  
Exit 
# -->End of Svcslst
