permissionscondawindows-servermulti-user

Access is denied error when running cmd as different user


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: enter image description here

I also tried to run the bat file as a different user, then I get the following error: enter image description here

enter image description here

Here are the contents of the bat file: enter image description here

The operating system in question is Windows Server 2016 Standard.

Any idea why we are getting this error and how we can resolve it?


Solution

  • The issue has been resolved by creating a scheduled task and ticking the "Run with highest privileges" box:

    enter image description here