How to access UNC path with credentials?

I am looking for the ways to access UNC paths which require credentials. I am currently using Matlab 2016b. Please help.

 採用された回答

Guillaume
Guillaume 2017 年 11 月 10 日

0 投票

There's no direct way to access them in matlab. You probably could go through Java, or if on Windows, through .Net, but probably the simplest would be to mount the UNC through the OS. if on windows:
drivename = 'U:'; %whichever you want
unc = '\\somewhere\somepath\
user = 'username';
password = 'password';
system(sprintf('net use %s "%s" /user:%s %s', drivename, unc, user, password));

2 件のコメント

Jan
Jan 2017 年 11 月 10 日
While this is a good solution, remember, that storing passwords in clear text is a really bad idea.
Colin
Colin 2021 年 3 月 17 日
Can you recover the clear text password if the script is compiled into an application?

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2017 年 11 月 10 日

コメント済み:

2021 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by