How to get drive letter of mapped network drive

a 夏天 提交于 2021-02-07 10:41:51

问题


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?


回答1:


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

this should work ;)



来源:https://stackoverflow.com/questions/19555441/how-to-get-drive-letter-of-mapped-network-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!