Migrating some Excel Automated code using C# off an old Windows 2003 Server onto Windows Server 2012 R2 and using Scheduled Tasks to run I notice it was failing. User linked to the Scheduled Task has correct permissions and it is being run with highest privileges. Excel installed and I can run the code manually fine as that user. Plenty of threads about the issue but the only thing that worked was:-
FIX
Windows 2008 +
Add 2 directories:-
%windir%\System32\config\systemprofile\Desktop
and
%windir%\sysWOW64\config\systemprofile\Desktop
Windows 2012 r2
Add 2 extra directories:-
%windir%\SysWOW64\config\systemprofile\Documents
and
%windir%\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache