c# - C# Win App, Task Scheduler, User Account: System. Microsoft Excel cannot access the file
问题描述
- Task Scheduler on a Windows server
- User Account is System
- Starts a .NET windows app that reads an Excel file
- 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
andC:\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?
解决方案
您没有说明文件:“D:\Automation\02_14_25_.xlsx”
实际存在,或者这只是您无法正确解释的错误消息。
在这种情况下,我的回答是:如果您的应用程序作为计划任务运行,则它没有使用正确的环境变量启动。这是我的经典错误:
“当我手动运行它时它可以工作,但当我使用 cron/计划任务时它不起作用。” - 设想
推荐阅读
- flutter - 如何在flutter中向fl_chart添加滚动条?
- python - StemGraphics 输出(无输出)
- c++ - 类没有友元方法的成员
- ios - Flutter Firestore 读写响应在 Ios 中非常慢
- javascript - Map.foreach 中的渲染组件
- java - 我想从一个 API 响应体中获取价值,并使用 Cucumber gherkin 将其用于另一个 api 请求
- jquery - 如何验证重复的表格?
- ios - 如何解决颤振中的“allowsBackgroundLocationUpdates”错误
- c# - 使用 Blazorise DataGrid 在移动设备上隐藏一些列
- ruby-on-rails - 资产管道中不存在资产“rails_admin/rails_admin.css”。):