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
Services Xbase++
Re: Services Xbase++
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.
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."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Services Xbase++
Ooooo. Thank you very much Tom you made my whole day



Re: Services Xbase++
Add:
After you added a ServiceController:
you can check the status of the service:
And you can find out what you can do with the service:
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.
After you added a ServiceController:
Code: Select all
oCtrl := ServiceController()
oCtrl:AddController("Advantage",<cPathToAdvantage>,...)
Code: Select all
? oCtrl:GetUpdatedControl("Advantage"):currentState
Code: Select all
? oCtrl:GetUpdatedControl("Advantage"):controlsAccepted
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Services Xbase++
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
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
Re: Services Xbase++
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.
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."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Services Xbase++
Anyway thank you very much for your help TOM
I will use net stop and net start
I will use net stop and net start