Click here to Skip to main content
15,885,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So i have a coded UI test that works fine. I've create a batch file script so that i can run in windows task scheduler. It keeps showing "Failed"

What I have tried:

cd /
cd "C:\Users\alish\source\repos\CodedUITestProject6\CodedUITestProject6\obj\Debug\CodedUITestProject6.dll "



@echo off
set max=.set count=.
echo starting test execution
echo =======================
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" /testcontainer:C:\Users\alish\source\repos\CodedUITestProject6\CodedUITestProject6\obj\Debug\CodedUITestProject6.dll/test:CodedUITestMethod1



echo all done
@exit
Posted
Updated 10-Feb-19 0:24am

1 solution

Probably, it's a permissions problem: the Scheduler does not run under your user ID, so it won't have access to your files. Try moving the data and DLL files to a different folder - "Tests" hanging directly off the root is good - and set the access permissions on the Tests folder to all for everyone.
Then change your batch script to use that folder instead of your user data, and it should work.
 
Share this answer
 
Comments
Member 14144306 10-Feb-19 6:38am    
I put all the data and dll files into a folder called Tests under C drive. And i changed the directory. It still doesnt work :(
OriginalGriff 10-Feb-19 6:45am    
Did you set the permissions correctly?
Did you change the batch file to the new paths?
Show us what you ended up with.
Member 14144306 10-Feb-19 6:59am    
Sorry, what you mean by permissions? Because currently i'm just trying to run the bat file on its own. If it works, then will import in windows task scheduler. It's giving me the same error- "Failed"
Member 14144306 10-Feb-19 7:03am    
cd /
cd "C:\Tests\CodedUITestProject6\bin\Debug\CodedUITestProject6.dll"



@echo off
set max=.set count=.
echo starting test execution
echo =======================
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" /testcontainer:C:\Tests\CodedUITestProject6\bin\Debug\CodedUITestProject6.dll/test:CodedUITestMethod1



echo all done
@exit
OriginalGriff 10-Feb-19 7:15am    
Don't nest your paths yet: get it working in a basic example first, then worry about the rest. So copy the DLL file into "Tests" directly, and move the EXE file there as well to be on the safe side (along with any other files they rely on)

Permissions: Right click the Test folder in Windows Explorer, and select "Properties" - select the "Security" tab".
See here for an overview: https://www.dell.com/support/article/uk/en/ukbsdt1/sln156352/understanding-file-and-folder-permissions-in-windows?lang=en

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900