Arvin
Arvin

Reputation: 1431

How to get drive letter of mapped network drive

I need to create a script or batch file to run on multiple computers that unmaps a network share \\serverName\shareName and maps a new network share \\newServer\newShareName

I can unmap the network drives by using:

net use /delete X: 

and map the new share with:

net use * \\newServer\newShareName

but the problem is the drive letter is going to be different on every computer.

How would I check what letter \\serverName\shareName is mapped to?

Upvotes: 3

Views: 2415

Answers (1)

cure
cure

Reputation: 2688

for /f "tokens=2,3" %%i in ('net use') do if '%%j=='\\servername\sharename set drive=%%i

this should work ;)

Upvotes: 6

Related Questions