Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to enumerate services
#3
Strange, the following code can run successfully

At present, I am not familiar with C#. I want to implement the functions of viewing service status, running, stopping services, etc. I am worried that the components that are too old are not working well. Can you use C# to provide sample code with the same function? thank you very much


Macro Macro1
Code:
Copy      Help
Services.clsService se._create
BSTR dispName="Quick Macros"

se.DisplayName=dispName
if(!se.ServiceType) mes- "Service not found." "" "x"

str state
sel se.CurrentState    
,case Services.Stopped state="stopped"
,case Services.Start_Pending_20 state="start pending"
,case Services.Stop_Pending_20 state="stop pending"
,case Services.Running state="running"
,case Services.continue_pending_20 state="continue pending"
,case Services.Pause_Pending_20 state="pause pending"
,case Services.Paused state="paused"    
,case else state="unknown"
int i=ListDialog("Start[]Stop[]Pause[]Continue" F"Current state: {state}")
if(!i) ret
if(!IsUserAdmin) mes- "To change service state, QM must be running as admin." "" "x"
sel i    
,case 1 se.StartService    
,case 2 se.StopService    
,case 3 se.PauseService
,case 4 se.ContinueService


Messages In This Thread
Unable to enumerate services - by win - 11-15-2018, 02:35 AM
RE: Unable to enumerate services - by Gintaras - 11-15-2018, 07:34 AM
RE: Unable to enumerate services - by win - 11-15-2018, 09:31 AM
RE: Unable to enumerate services - by Gintaras - 11-15-2018, 09:49 AM
RE: Unable to enumerate services - by Gintaras - 11-15-2018, 11:54 AM
RE: Unable to enumerate services - by win - 11-15-2018, 02:50 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)