Sen2Cor 2.5.5 Crashes when Started from Task Scheduler

Each time I try to start L2A_Process.bat from Task Scheduler in Windows the process crashes with a message saying: “Cannot create the config object configPic.p, parent folder may be write protected.”

I have tested running on datasets located on a network disk and on my local PC. Same result. A new L2A product folder is created and all folders down to …/GRANULE/L2A_T32VPP_A009300_20170403T104138. But no files or directories are created at this location. Somehow, this folder is write protected!?

The funny thing is that when I run the same batch script from the command window, it all works just fine. I made sure I am the user that runs the script launched from Task Scheduler.

Any idea what causes this error?

:: Print user name
echo User name: %username%
set Sen2Cor=C:\Users\argj\AppData\Local\Sen2Cor-02.05.05-win64\L2A_Process.bat
::set Sen2Cor=C:\Users\argj\AppData\Local\Sen2Cor-2.4.0-win64\L2A_Process.bat
set safe_fn=E:\Data\S2\T32VPP\R008\2017\S2A_MSIL1C_20170403T104021_N0204_R008_T32VPP_20170403T104138.SAFE
echo %Sen2Cor% --resolution=60 %safe_fn%
timeout /t 10
:: launch job
%Sen2Cor% --resolution=60 %safe_fn%
timeout /t 30 /nobreak