Page 1 of 1
Recognize a network-url
Posted: Tue Feb 05, 2013 12:12 am
by Nobackup
Hi!
I write a macro that must do something with a document if the document is stored on a networkdrive on windows.
My network drive \\server\mm\ is mapped to D:\ . The Document-URL is always file:///D:/myfile.ods.
How can I find out the real network path.
(In Excel with VB I can test with WNetGetConnection(...) for a vality network path.)
Thanks very much
Re: Recognize a network-url
Posted: Tue Feb 05, 2013 1:06 am
by rudolfo
Network mapped drives on MS Windows means that the servername and the name of the SMB share are mapped to a drive letter. This means if you have a UNC path \\server\mm\ that is mapped to drive D:\ everything that comes behind this will be the same:
\\server\mm\a-very\deep\directory\path\with\a-file.txt
will become
D:\a-very\deep\directory\path\with\a-file.txt
If you know that \\server\mm is the UNC path for the network mapped drive your problem is solved. It is simply a question of string substitution.
But it seems like you are rather asking how you can find out wether a drive E: is a local drive or a network drive. Your only chance is to ask the OS: Try the gold old
net use. If you are using Basic as a programming language you will have a pretty hard time to capture its output and parse it for the string
E:.
Python makes this a lot easier with the open() and popen() commands.
Code: Select all
C:> net use
Status Lokal Remote Netzwerk
-------------------------------------------------------------------------------
OK E: \\iova\shared Microsoft Windows Network
Re: Recognize a network-url
Posted: Tue Feb 05, 2013 1:35 am
by karolus
Hallo
Additional to Rudolfo:
Do explizit test with:
>: net use D:
Karolus