Forum Discussion

John_Laird's avatar
John_Laird
Contributor
8 years ago
Solved

Issue using powershell with TestComplete12

My goal is to start/stop services via powershell called from a TestComplete script (python). So I read (and attempted to apply) the info in this article to do just that:   https://support.smartbear...
  • John_Laird's avatar
    John_Laird
    8 years ago

    I tried this and it worked, probably because it uses the windows native command shell instead of powershell:

    def stopLogServ():
      Sys.OleObject["WScript.Shell"].Run("sc.exe stop asiLOGSERVER")
      Sys.OleObject["WScript.Shell"].Run("sc.exe stop asiLOGGER")

    Your suggestion to use this works as well:

    WshShell.Run("net stop asiLOGSERVER")

    I realized this morning that I was running TestComplete in administrator mode which is why the above works.

     

    Powershell with equivalent commands (sc.exe stop asiLOGGER) and TestComplete running in admin mode just throws access denied errors. Must be something different in how the powershell session is started from TestComplete.

     

    When I restart TestComplete without checking the box for administrator mode, the above commands fail. So I'll just run TestComplete in adminstrator mode and not use powershell with commands that need elevated permissions.