Weird access issue between stages

I came across a very strange issue, where I run a exe file that relies on a directory that is downloaded during a build.
I ran this exe in one stage with no problems, but when I ran it in next stage again with different parameters it failed because some paths were not accessible by Continua context.

I tried to debug it but failed miserably…
From withing Continua context couple of files and one directory was not visible nor accessible (dir command ran through cmd) but when I logged in to the agent PC everything was there…
I ran this multiple times with no success, I ran the exe by Run executable action and via Cmd action, always with same result.
I verified that all paths had the same owner and permissions, as expected as all were created by Continua context.

My solution to this problem was to run twice the same exe in the same stage, then it works…

It’s something probably connected with permissions on windows, but I have no idead what could lead to this and how to detect what is actually wrong.
Does every stage create some temporary shell or something ?

Hi Michal,

Each stage runs in the agent service process with permissions associated with the user account that the agent service is logged in as. No “temporary shell” is created. Each action which calls an executable starts a separate process, running under the same account as the agent service, using Process.Start with UseShellExecute set to false and LoadUserProfile set to true.

We’d need to see a build log to understand what is happening in your scenario. Is it possible that another build or external process is removing the directory? How are you creating the directory - maybe the process to create the directory has not yet completed when the next process tries to access it?