0

I have Task Scheduler on a Windows server; the User Account is System. This task starts a .NET windows app that reads an Excel file, but it shows the error:

Microsoft Excel cannot access the file 'D:\Automation\02_14_25_.xlsx' There are several possible reasons:

  • The file name or path does not exist.
  • The file is being used by another program.
  • The workbook you are trying to save has the same name as a currently open workbook.

I created the folder Desktop in C:\Windows\SysWOW64\config\systemprofile and C:\Windows\System32\config\systemprofile\ but still same error.

When I log in to the server as myself(administrator) and run the app, it runs without errors.

Any suggestions please?

1
  • %SystemRoot% (ie: C:\Windows) is a protected directory (as well as folders beneath it) and requires administrative privileges. Commented Dec 18, 2020 at 22:17

1 Answer 1

3

You did not clarify that the file: "D:\Automation\02_14_25_.xlsx"

Actually exists or if that is just the error message you could not correctly interpret.

In that case my answer would be: Your application is not started with the correct environment variables if it runs as a scheduled task. That is my classical mistake for the:

"It works when i run it manually but it doesn't when i do it with cron/scheduled task." - Scenario

Sign up to request clarification or add additional context in comments.

4 Comments

The file does exists. No arguments/parameters are needed. When I run it manually, I just double click the exe file. Thanks
I see that you did something quite helpful, and although you're right that this should maybe be a comment, I gave you an upvote so you can make helpful comments in the future.
This answer didn't provide any help. I'm still unable to open/read the Excel file.
Have you tried running it as a regular (administrative) user? Some applications refuse to run as system user. Also iam confused as to why you created a folder named Desktop at the named locations. That seems pretty random so we are likely missing some vital information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.