Allowing old Matlab to use DOS command under UNC path

Hello everyone,
I have to use Simulink models with UNC path. My problem is : matlab before release R2009a is unable to use the DOS command under the UNC path.
I have read a bug report from MathWorks on the link below : https://fr.mathworks.com/support/bugreports/340552?s_tid=srchtitle
I have followed all the step writing on the tutorial but it is not working either. I can't upgrade my models (technical issue), so I would like to know if someone knows a way to "upgrade" my Matlab installation folder to be able to use DOS command under the UNC path (with release under than the R2009a).
Thank you for your answer :)

 Accepted Answer

The bug report that you link applies to the Real Time Workshop only and it looks like the solution works around the issue by not calling dos. So I'm not sure how it applies in your case.
Anyway, can't you just map the UNC to a local drive and work from the local drive? This is actually what mathworks suggests in the documentation of the dos command (under limitations).

10 Comments

By "Map the UNC to a local drive" you mean building a path with a letter like D: or I: ?
Yes, as per the link. Probably the easiest way is to enter at the windows command prompt:
net use M: \\servername\xx\xxx
and use 'M:' (or whichever letter you prefer) instead of '\\servername\xx\xxx' in matlab.
Ok right, but my problem is that I can't use a letter. The aim of my work is to make free a letter ^^ because all the others are already used and my folder where I have my models is quite heavy. Do you have an other solution without using a letter?
Completely untested: you could create a directory symbolic link to the UNC folder. At the windows command prompt:
mklink /D C:\somewhere\somename \\servername\xx\xxx
Be aware that symbolic links can confuse some programs.
Would be a great idea on my view but my first issue is that Matlab under R2009a is unable to use Windows command ^^ I was looking for something like editting my old Matlab release to support this kind of path.
As I have read on the link in my topic there seems to be a way of doing this.
If you know things on that? ^^
I don't understand why you can't create the symbolic link outside matlab straight from windows command prompt.
Failing that, you can always call the raw win32 API CreateSymbolicLink straight from matlab. Create a header file (e.g.: kernel32.h) with just the line:
unsigned char __stdcall CreateSymbolicLinkA(char* lpSymLinkFileName, char* lpTargetFilename, unsigned long dwFlags);
And you can then create symbolic links with
loadlibrary('kernel32', 'kernel32.h');
calllib('kernel32', 'CreateSymbolicLinkA', 'C:\somewhere', '\\servername\xx', 1); %1 to create a directory symlink, 0 for a file symlink
Or you can defer to Java CreateSymbolicLink (assuming your version of matlab ships with Java 7):
fs = java.nio.file.FileSystems.getDefault;
localpath = fs.getPath('C:\somewhere', javarray('java.lang.String', 0));
unc = fs.getPath('\\servername\xxx\xx', javarray('java.lang.String', 0));
attribs = javaArray('java.nio.file.attribute.FileAttribute', 0);
java.nio.file.Files.createSymbolicLink(localpath, unc, attribs)
Why not system() the command? MATLAB before R2009a was certainly able to use system()
Maybe I haven't explain very good, sorry for my English skills. The UNC path is already created and my model is on it already. I want to run the model from the UNC path.
You maybe good understand and it is my bad if I don't understand what you explain, so can you tell it an other way? I am not a Matlab expert. ^^
Well, if you want to work from a UNC path, then you need to get rid of any call to the dos command. Not being familiar with simulink, I don't know if being able to call dos is required in versions < R2009b. If it is, you simply won't be able to work from a UNC path.
What is the exact error you're getting, anyway?
Here is my error:
If I translate the french sentence Under the blue linnk you have : CMD.EXE run with the current path. UNC path are not alowded. Windows directory used by default. Access denied

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!