user441521
user441521

Reputation: 6998

vbscript called from batch file from task scheduler failing to open excel workbook

I have a vbscript that I'm calling from a batch file. Inside this script it opens an excel file on a sharepoint site. When I run this batch file by dbl clicking it everything works. When I run from the task scheduler the log file shows it's failing to open the excel file on the line:

XL.Workbooks.Open(wrkbook)

Note that it works fine when dbl clicked. I'm guessing it's some kind of permissions or something but not sure who/what/when/where/why. Any ideas?

When I pipe the vbscript error I get:

Microsoft Excel cannot access the file 'file path here' for one of the following reason:

Upvotes: 2

Views: 972

Answers (1)

user441521
user441521

Reputation: 6998

OMG, you have GOT to be kidding me. The answer is a handful of posts below in this thread and you'll never believe it.

https://social.msdn.microsoft.com/Forums/office/en-US/ac2549f5-fc1e-494d-9015-70cb31d3aeb2/opening-excel-workbook-fails-when-run-from-scheduled-task-on-windows-server-2008-rw?forum=exceldev

Literally, and I'm not joking here, all I had to do was create a a folder named 'desktop' in C:\windows\SysWOW64\config\systemprofile. So the final path is 'C:\windows\SysWOW64\config\systemprofile\desktop'.

Can you believe that? That's insane.

Upvotes: 2

Related Questions