Error using copyfile function in Matlab2020b
古いコメントを表示
Hello,
I am trying to experiment the usage of copyfile for copying a .jar file for source location to destination. I have written a test script that takes the jar file from the current location and move it to a destination folder "C:\Program Files\MATLAB\R2020b\sys\java\jre\win64\jre\lib\ext".
However I keep getting error message that "The system cannot find the file specified".
I can confirm that the file is located on the same path where my script TestFileTransfer.m is located. When I change my destination location to somewhere NOT under "C:\Program Files", the script works perfectly fine. Does anybody have any idea what might be the issue ? anything related to ADMIN rights ?
Here is the script snippet TestFileTransfer.m
when the dest_fldr = "C:\temp", it works fine.
testfile = 'testfile.jar';
dest_fldr = "C:\Program Files\MATLAB\R2020b\sys\java\jre\win64\jre\lib\ext";
%dest_fldr = "C:\temp";
if (exist(testfile,'file'))
try
copyfile(testfile, dest_fldr, 'f');
catch e
disp(e.message); %The system cannot find the file specified
end
else
error('File does not exist');
end
6 件のコメント
Ive J
2022 年 1 月 11 日
I would guess you need special permissions for that. Have you tried with admin account?
Pratik Chachad
2022 年 1 月 11 日
Walter Roberson
2022 年 1 月 11 日
No, there is no way to do it through MATLAB. You are trying to bypass Microsoft UAC (User Account Control), which was built in to Windows starting about Windows 7. In order to make it harder for malware to infect a system, you need system privileges to write into C:\Program Files
Pratik Chachad
2022 年 1 月 12 日
Max Heimann
2022 年 1 月 14 日
What if you launch matlab with admin privileges? Not that this would neccesarily be a good idea, but would it give matlab the needed priviliges?
Ive J
2022 年 1 月 14 日
編集済み: Walter Roberson
2022 年 1 月 14 日
@Max Heimann yes that would work.
file = "something";
dest = "C:\Program Files\MATLAB\R2021b\sys\java\jre\win64\jre\lib\ext";
copyfile(file, dest) % works even without 'f' flag
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
