PowerShell won't run Excel from a scheduled task

Just ran head-on into what appears to be a bug in the .NET Excel object in PowerShell.



It appears to be a known bug but there is not a lot of info about it.  The bug does not allow Excel to be run from a task in windows task scheduler unless the task author has checked the “user has to be logged on to run” option.

The issue is that Excel tries to do a “CreateFile” operation in “C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files”.  The problem is that the Temporary Internet Files folder doesn’t exist in that location.

Until Microsoft fixes this the solution work-around is to create two folders:

  • "C:\Windows\System32\config\systemprofile\Desktop" (Create on both 32 bit and 64 bit systems)
  • "C:\Windows\SysWOW64\config\systemprofile\Desktop" (Create only on 64 bit systems)

Once these are created and the scheduled task is re-run, everything should work fine regardless if you are running the task with "Run whether user is logged on or not" is checked.  

Comments

Popular posts from this blog

How to use PowerShell to find what computer a user is CURRENTLY logged into.

New script storage location