Forum Discussion

    • VasanthVijay's avatar
      VasanthVijay
      Contributor

      Hello ,

                 I already refered this link.But same code i use and it not affect on the Services .

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        -- Did you check in Task Manager that the relevant service process starts/stops?

        -- Does the account that executes the start/stop code have anough privileges (as mentioned in the referenced article)?

        -- Can you post here your actual code?

        -- Any related messages in the Windows Event Viewer logs?

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Vasanth,

     

    You may either execute 'net start/stop' command using WScript.Run() or do this via WMI (google for something like "WMI stop windows service").

    You may also search this forum - there were a couple of samples here on how to do this using WMI.

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    hi,

    I just scripted that a few days ago :

     

    procedure xxxx

    var
      wmiService, service;
    begin
      wmiService:= WMI.Service;
      service:= wmiService.Get('Win32_Service.Name=''theServiceName''');
      service.StartService

     

    please note that "theServiceName" is to be changed by the service name as it appears in windows services

     

    also, "service.StopService" stops the service

     

    finally, both return an integer. 0 indicates that the operation has correctly been processed.

     

    see this page for all return codes :

     

    https://msdn.microsoft.com/en-us/library/aa393660(v=vs.85).aspx