How to pass username and password to network location
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I am trying to programatically access the network share under MATLAB dir command. It is working perfectly till the network is not password protected.
I am trying to pass the credentials as follows
dir('\\server\share /user:test testpassword')
but it gives me the "not found. Check the path or file permissions." error. I appreciate any hints.
0 Kommentare
Akzeptierte Antwort
dpb
am 20 Jun. 2024
<dir> doesn't know anything about user; there is no switch processing so it thinks you're looking for a file named
\\server\share /user:test testpassword
as the file.
Try just
dir('\\server\share')
or
dir('\\server\share\*.*')
For a test,
>> dir('\\mfs0.sccc.edu\DevelopAlumni')
. ERF-Employee-Requisition-Form.doc STUB.LOG
.
.
.
works here when connected via VPN to the college...although I do have the drives mapped so that
dir('H:')
will produce the same result. The login credentials are handled by the VPN interface and the (Windows OS)
net use H: \\networksharename USERPASSWORD /USER:username /PERSISTENT:YES
I suspect you'll have to do something similar first to establish the link.
2 Kommentare
dpb
am 21 Jun. 2024
Bearbeitet: dpb
am 21 Jun. 2024
Clearly it is not mapped permanently as you think...and I have no idea what you're thinking about in the "Matlab 'dir' takes the default Windows credentials to log in to a drive.". dir simply passes the file name to the OS and doesn't have concept of logging in specifically for the given time; the network drive is either already mapped/accessible to the session or it isn't.
What does
!net use
from the command line return? It is not going to show your network drive, I'm sure.
Have you executed the net use
net use H: \\networksharename USERPASSWORD /USER:username /PERSISTENT:YES
from a command session and verified after that the drive is mapped? That is what I do routinely when logging in and connecting to the remote machine through the VPN. For convenience, I've put the commands for all the drives I map (various locations on the same physical drive) in batch files so don't have to type out the whole thing every time, but this has to be done (but only once) every session.(*)
If that doesn't solve your problem, you'll have to talk to your local IT people about specifics for your system...
(*) That's user session, not per MATLAB instance or any other application; if the system has the drive mapped, it's global.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!