cancel
Showing results for 
Search instead for 
Did you mean: 

Running batch file as admin from Test Complete

SOLVED
Contributor

Running batch file as admin from Test Complete

Hi,

I have a batch file which needs to be run as adminstrator. This batch file contains scripts to start and stop a service and windows 10 only lets it to be executed as administrator. How can i run this batch script as administrator in TestComplete's TestedApps?

 

Thank you for helping,

Sudha

4 REPLIES
Frequent Visitor

Re: Running batch file as admin from Test Complete

Hello.
At the moment there is no integrated functionality in TestComplete which let you run TestedApps with elevated token if TestComplete itself runs without it. However if some environment preconfiguration is acceptable in your testing scenario you can use Windows Task Scheduler to workaround this limitation. Just create a new task which runs your batch with "Run with the highest privileges" parameter set to enabled and launch this task from TestedAps. You can find additional information about creation and launch of Windows tasks here:
https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks

Community Hero

Re: Running batch file as admin from Test Complete

Hi Sudha,

 

As @VladYatskovskiy said, processes started from TestComplete inherit its level of permissions.

What I would recommend is to start your batch file via Powershell and command it to launch this batch file with elevated permissions (https://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator, https://ss64.com/ps/syntax-elevate.html).

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
Community Hero

Re: Running batch file as admin from Test Complete

If you have the option, you could always run TestComplete as an administrator.  I don't know if this is a security/policy issue for you.  When you do so, then anything you execute within TestComplete is run with that privilege level.  

That said, rather than using a batch file, you could always use the WshShell Object to execute a command line to start/stop as service.  This is what I've used in the past and is much easier to keep track of than the location and contents of batch files.  See https://support.smartbear.com/testcomplete/docs/reference/program-objects/wshshell/index.html


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Contributor

Re: Running batch file as admin from Test Complete

Thanks to everyone for the replies. I ran TestComplete as an administrator as Robert Martin suggested and i could run the batch file as an administrator.

Watch a new Video
Top Kudoed Authors