ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: Service   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

dim. 12 février 2012, 15h16
Mike Gagnon
Canada Canada

atoutfox.public.association

Re: Service

Tu peut arreter (repartir) un service avec WMI

? StopService( ".", "Adobe LM Service")


Procedure StopService(tcComputer, tcServiceName)
  Private  loService
  objWMI = Getobject("winmgmts:\\" + tcComputer + "\root\cimv2")
  loServices = objWMI.ExecQuery("Select * from Win32_Service",,48)
  &&Get the WMI administration object'
  && Check base properties'
  For Each loService In loServices
    If loService.Name = tcServiceName
      If loService.Started = .f.
        ? "The service " + tcServiceName + " is Not started"
        Exit
      Endif
      If Not loService.AcceptStop
        ? "The service " + tcServiceName + " does Not accept stop command"
        Exit
      endif
      loService.StopService
      Inkey(5)
      If 0 <>  loService.StopService
        ?"Stop " + tcServiceName + " error: " + Transform(loService.StopService)
        Exit
      Endif

      Do While loService.Started
         lnResult = loService.StopService
        ? Datetime(), "StopService", tcServiceName,loService.Started,loService.State, loService.Status
        Inkey(1)
        Loop
      Enddo
    Endif
  Endfor
   ? 'Service stopped at '+ ttoc(datetime())


Endproc



Permalink : http://www.atoutfox.org/nntp.asp?ID=0000008177
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3