Forum Discussion

LAB's avatar
LAB
Contributor
8 years ago

Start a service in keyword test

I've seen the code for jscript and vb, I tried pasting the jscript version into a script and referencing that via "Run Script Routine", entering computer and service name...

 

When testcomplete tries to execute this section, I get the following error.

 

Error
Invalid number of parameters.
Error location:
Unit: "ProjectSuite\Project\Script\Unit2"
Line: 62 Column: 16.
 
which references this section of the script-

 

  wmiService = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\\\" +

     computerName + "\\root\\cimv2");

 

I noticed on the help page it mentions I need to set WMI security permissions, and I did set those permissions as well. Do I need to change anything in this section? Tried changing computerName to my actual computer name but no dice

9 Replies

    • LAB's avatar
      LAB
      Contributor

      had to split it up due to character limit, but this is what I found on smartbear website

      function Test()
      {
        StopService(".", "TestComplete 7 Service");
        Delay(10000);
        StartService(".", "TestComplete 7 Service");
      }
      
      function StartService(computerName, serviceName)
      {
        var service = GetService(computerName, serviceName);
        if (service == null) {
          Log.Warning("The " + serviceName + " service on the " + computerName + " computer was not found");
        }
        else {
          service.StartService();
        }
      }
      • LAB's avatar
        LAB
        Contributor
        function StopService(computerName, serviceName)
        {
          var service = GetService(computerName, serviceName);
          if (service == null) {
            Log.Warning("The " + serviceName + " service on the " + computerName + " computer was not found");
          }
          else
            service.StopService();
        }