Translate file name in mapped drive to unc path filename

3 views (last 30 days)
L
L on 28 Jun 2022
Answered: Jan on 29 Jun 2022
Hello! Which function translates file name given in mapped drive path to file name given in UNC path? For example: z:/abc/test.m to //nettapp1/abc/test.m Thanks in advance!!
  3 Comments
dpb
dpb on 28 Jun 2022
" I know there is a Matlab function which does this automatically..."
I don't believe there is any such thing in base MATLAB. Maybe somebody has posted something on FEX, but unless there's a java method (and I don't know that there is), capturing the output from NET USE is the ticket for a Windows box.

Sign in to comment.

Answers (1)

Jan
Jan on 29 Jun 2022
No, there is no Matlab command to perform this automatically.
net use sovles this and WMIC can help also:
[status, out] = system('wmic path win32_mappedlogicaldisk get deviceid, providername');
List = strsplit(out, '\n');
Line = List{startsWith(List, 'Z:')};
UNC = strtrim(Line(3:end));
Or parse the output of the PowerShell command:
Get-WmiObject Win32_NetworkConnection | where -Property 'LocalName' -eq 'Z:' | ft "RemoteName","LocalName" -A

Community Treasure Hunt

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

Start Hunting!