In our organisation we often automate tasks using Windows Task Scheduler. In a typical scenario, we have a bat file that calls python to execute a piece of code. After adopting virtual environments in Python we ran into an issue where we get an "Access is denied" error when calling the bat file using a service account.
To reproduce the error I opened cmd as a different user and provided our service account's credentials. The service account has sufficient permissions to navigate to the directory of conda.bat but gives an error when I try to run the bat file:
I also tried to run the bat file as a different user, then I get the following error:
Here are the contents of the bat file:
The operating system in question is Windows Server 2016 Standard.
Any idea why we are getting this error and how we can resolve it?
The issue has been resolved by creating a scheduled task and ticking the "Run with highest privileges" box: