I'm trying to find a way to retrieve the users mapped drive letter from a network drive. I've read a few posts here but they all seem to be around mapping/unmapping drives, whereas I simply need to know what drive the user has that network drive mapped to.
From a command prompt I use: Net Use s: for example will give me the name of the networked drive (\servershare\file\sharename\shared), however
Net Use \\servershare\file\sharename\shared
just gives "The command completed successfully", where I need 'S:' returning.
How do I get the drive letter returned for a specific network drive?
A batch file like this will work:
Notes:
ECHO Drive letter is %%Dwith whatever code you want now that the drive letter is known, possibly a multi-line code block surrounded by(and). Replace\\SERVER\SHAREwith the share you're looking for.DOwill never execute. If there's more than one drive mapped to the share, it will execute once for each drive.^| find ":"pipe if you're sure there won't be any connections without a drive letter (e.g. created withnet use \\SERVER\SHAREas opposed tonet use S: \\SERVER\SHAREornet use * \\SERVER\SHARE)./Iswitch if you're sure there won't be any connections to the share using different character case.@characters prevent the commands from echoing on the console. An alternative is to begin the batch file with@ECHO OFF'.%%Dwith%D.