writetable() has write permission problems when run as scheduled task; save() does not

67 ビュー (過去 30 日間)
Scott
Scott 2017 年 3 月 30 日
回答済み: Tharikaa Ramesh Kumar 2024 年 6 月 12 日
I have a script that checks a folder for accumulating images, processes them, and builds a table of data about the images. The script then saves the table in two ways: first, as a .mat file via the MATLAB save() function, and then as an Excel spreadsheet via the writetable() function into the very same folder.
The script works perfectly in an interactive MATLAB window.
However, when I try to run the script via Windows' Task Scheduler, the writetable part fails due to a permissions error while the save() works just fine to the very same location. I have given the scheduled task my user credentials, and the fact that the .mat file gets written suggests to me that the script has write permission the folder. writetable chokes, however.
The error I get (seen via the -logfile parameter to MATLAB in the scheduled task) is:
Unable to save the workbook to file 'D:\ImageList2017-03-30.xlsx'. Check
that write permissions are available, there is sufficient disk space, and
the file can be written to or created.
And the error points to:
C:\Program Files\MATLAB\R2016b\toolbox\matlab\iofun\writetable.m line 121.
This is on Windows 7, writing to a local disk (eventually I want it to work with an UNC path to a shared folder), using MATLAB R2016b.
Ideas?
Edit for additional information: I changed the filetype of the file being written by writetable() to be .txt, and that worked just fine with no permission errors. So this seems to be an issue with writing .xlsx. Is Microsoft Office misbehaving here?
  4 件のコメント
Victor Villar
Victor Villar 2019 年 5 月 24 日
編集済み: Victor Villar 2019 年 5 月 24 日
Maybe this could help:
https://www.mathworks.com/matlabcentral/answers/463778-windows-task-scheduler-does-not-produce-any-output-when-setting-tasks-with-xlswrite
Tharikaa Ramesh Kumar
Tharikaa Ramesh Kumar 2024 年 6 月 12 日
Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

サインインしてコメントする。

採用された回答

Scott
Scott 2020 年 2 月 3 日
I found a bizarre, totally non-intuitive solution that worked. From Technet.microsoft.com
You have to create a folder (or two on a 64bit-windows):
(32Bit, always)
C:\Windows\System32\config\systemprofile\Desktop
(64Bit)
C:\Windows\SysWOW64\config\systemprofile\Desktop
I have had the same problem and this was the only solution i have found.
After creating the two above-named folders, the MATLAB script's writetable() call now correctly creates the .xlsx file.
  2 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 6 月 18 日
I pefromed above solution and it did not work. Then I shortened the address and it worked. It seems there is a limitation in the size of the address.
Ismaeel
Ismaeel 2022 年 1 月 14 日
編集済み: Ismaeel 2022 年 1 月 14 日
The second note mentioned by Zeynab Mousavikhamene worked for me. I was trying to save my table to (C:\Program Files\New Folder) and it did not work. I changed to C:\New_Folder (with no space) and it worked just fine. Thank you Zeynab and Scott for your contributions.

サインインしてコメントする。

その他の回答 (3 件)

Ahmed Rashid
Ahmed Rashid 2020 年 1 月 31 日
The error might also occur if the folder, in which the file is supposed to be save, does not exist.

Derek Smith
Derek Smith 2022 年 9 月 23 日
As the exact filename you are attempting to write is not given, I figure I can lend my $0.02. My problem was that, when trying to name a file according to a date, I did not format the date to remove colon markers. Once these illegal characters were removed, there was no problem.

Tharikaa Ramesh Kumar
Tharikaa Ramesh Kumar 2024 年 6 月 12 日
Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by