Forum Discussion

Jovani_smo's avatar
Jovani_smo
Occasional Contributor
12 months ago

How to start service Windows with TestComplete

Hi guys!
I'm using Windows 10 and TC 15.54.
Using WMI.GetServiceState I can get the status of the service, in this case it is Stopped.
How do I start this service through TestComplete?

I already tried, but it didn't work...

 

var ServiceName = 'Sysmo S1 Task Scheduler';

WshShell.Run("net start" + ServiceName);

  • Yes, it works... I solved it by opening the CMD screen and running there 🙂

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You might not have elevated privileges to run WshShell.Run, as the permissions are inherited from TC. If you were to run TC as an Administrator, then it will work.

    • Jovani_smo's avatar
      Jovani_smo
      Occasional Contributor

      Hi rraghvani!

      I tried to start TC as an administrator, and run the command WshShell.Run("net start" + ServiceName); but it still didn't start the service 😞

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I've just tried this, and it works

    I noticed that you are missing a space after start, so your string looks like this,

    net startSysmo S1 Task Scheduler
    • Jovani_smo's avatar
      Jovani_smo
      Occasional Contributor

      Even though you change it, the service still doesn't start WshShell.Run("net start " + ServiceName);

    • Jovani_smo's avatar
      Jovani_smo
      Occasional Contributor

      Yes, it works... I solved it by opening the CMD screen and running there 🙂