Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
8 years ago

How to start a service from TestComplete?

What is the approach to start a service from TestComplete?

 

For example: I have service "service1" which I want to start from TestComplete, prior to test execution. And, I want it to stop after test execution as well.

 

What would be the code (or Keyword test steps) to do this?

 

Thanks,

Mathijs

 

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      In the past, I've used the WScript.Shell object to simply run 'net start' and 'net stop' of any windows services.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Very simply, the code in JavaScript looks like this:

        function serviceStart(serviceName) {
            WshShell.Exec('net start ' + serviceName);
        }
        
        function serviceStop(serviceName) {
            WshShell.Exec('net stop ' + serviceName);
        }
    • mgroen2's avatar
      mgroen2
      Super Contributor

      shankar_r Thanks for your feedback. I can confirm that this solution works.