Services Xbase++

This forum is for eXpress++ general support.
Post Reply
Message
Author
MIGUELON
Posts: 135
Joined: Wed Feb 10, 2010 10:55 am

Services Xbase++

#1 Post by MIGUELON »

Hi everyone and happy new year
My question is: can I stop a windows service and start it again from Xbase++
I want to stop the Advantage engine.
Greetings and thanks for your attention
Miguel

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Services Xbase++

#2 Post by Tom »

Hi, Miguel.

Happy new year!

Xbase++ provides the ServiceController-class, which, for instance, lists all running services with "? ServiceController():QueryAllServiceNames()". It should be able to control any service by using ":AddController()" and methods like ":Start()" or ":Stop()" afterwards, if the :AddController()-method gets all needed parameters and user data.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

MIGUELON
Posts: 135
Joined: Wed Feb 10, 2010 10:55 am

Re: Services Xbase++

#3 Post by MIGUELON »

Ooooo. Thank you very much Tom you made my whole day :) :D

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Services Xbase++

#4 Post by Tom »

Add:

After you added a ServiceController:

Code: Select all

oCtrl := ServiceController()
oCtrl:AddController("Advantage",<cPathToAdvantage>,...)
you can check the status of the service:

Code: Select all

? oCtrl:GetUpdatedControl("Advantage"):currentState
And you can find out what you can do with the service:

Code: Select all

? oCtrl:GetUpdatedControl("Advantage"):controlsAccepted
The answer should be at least {"SERVICE_ACCEPT_STOP", "SERVICE_ACCEPT_SHUTDOWN"}. If so, you may stop the service from inside your app, and "SERVICE_ACCEPT_START" should be available afterwards.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

MIGUELON
Posts: 135
Joined: Wed Feb 10, 2010 10:55 am

Re: Services Xbase++

#5 Post by MIGUELON »

CLASS Logger
EXPORTED:
INLINE METHOD write( cMsg )
? cMsg
RETURN SELF
ENDCLASS

PROCEDURE ServiciosControl( cParam )
LOCAL cLocation, oLog, oCtrl, cServiceName
oLog:=Logger():new()
oCtrl := ServiceController()
oCtrl:AddController("Advantage",CurDrive()+":\"+CurDir()+"\Program Files\Advantage 10.10\Server\ads.exe","Administrador","ParaXXXion27",oLog)
mensaje(oCtrl:GetUpdatedControl("Advantage"):controlsAccepted,100)
mensaje({1,oCtrl:pause("Advantage")},100)
mensaje({2,oCtrl:stop("Advantage")},100)
mensaje({3,oCtrl:uninstall("Advantage")},100)

Hi Tom I can't get the service to stop.
As you say oCtrl:GetUpdatedControl("Advantage"):controlsAccepted
it returns "SERVICE_ACCEPT_STOP", "SERVICE_ACCEPT_SHUTDOWN"
But it does not listen to :stop() or :Pause() as you see in the code that I sent you.
Is there something I do wrong?
Thank you

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Services Xbase++

#6 Post by Tom »

Hi, Miguel.

I can't see an error and I get the same results here. Seems like the service doesn't stop although it should. Maybe a case for the Alaska support.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

MIGUELON
Posts: 135
Joined: Wed Feb 10, 2010 10:55 am

Re: Services Xbase++

#7 Post by MIGUELON »

Anyway thank you very much for your help TOM
I will use net stop and net start

Post Reply