Solved view mapped network drives command prompt

June 23, 2010 at 05:48:41
Specs: Windows XP sp2, 3mhz/2 gig
Hi all, I wanted to know if you have a batch script to view all mapped network drives?

Thank you

See More: view mapped network drives command prompt

Report •

June 23, 2010 at 06:52:04
✔ Best Answer
Hi, I managed to write some script. It does what it has to.

@echo off & cls & type nul> c:\123.txt

setlocal enabledelayedexpansion
for /f "tokens=* delims= " %%a in ('net use') do (
set line=%%a
if "!line:~0,2!" == "OK" echo !line:~13,2! !line:~23! & echo !line:~13,2! !line:~23!>> c:\123.txt


Report •

June 23, 2010 at 07:34:07
Or, you know, just
net use

Report •

June 23, 2010 at 08:52:15
Thanks Razor, I should have said I wanted the results of the drive letter and path only. Sorry about that.
But it works so I am happy.

Report •

Related Solutions

June 23, 2010 at 09:18:18
It may not work in all cases. Where you have !line:~13,2! it is
not necessarily just two characters (drive letter and colon). It
can be other things too. Here's a sample output of NET USE:

Status       Local     Remote                    Network

OK           Q:        \\londonfilesrvr1\dept_11$\Team_B
                                                 Microsoft Windows Network
OK           LPT1      \\londonprintsrvr2\LON3P1 Microsoft Windows Network
OK                     \\dilbert\IPC$            Microsoft Windows Network

So, as you can see, that column could contain a drive letter,
a special device name such as PRN or LPT1, or nothing at

Report •

June 23, 2010 at 10:17:52
Thanks Klint I see I need to review this for others. It did what I
needed to (luckily I guess) but to work properly I should use a
FOR loop with "tokens=2,3" and call a function to check the
line. I hope this helps others if they need it. Good thing you
brought that up. Cheers for your input

Report •

June 23, 2010 at 10:25:18
13:23:38>wmic path Win32_LogicalDisk Where DriveType="4" get DeviceID, ProviderName /format:list

ProviderName=\\Media-center\F Drive on MEDIA-CENTER

ProviderName=\\Media-center\F Drive on MEDIA-CENTER

ProviderName=\\Media-center\F Drive on MEDIA-CENTER

ProviderName=\\Media-center\F Drive on MEDIA-CENTER

Edit: I like my F Drive apparently! :-)
Insomniac at large

Report •

June 23, 2010 at 10:29:03
Failed to register mof file(s).
Only the administrator group members can use WMIC.EXE.
Reason:Win32 Error: Access is denied.

Or: There are restrictions to WMIC that no one seems to talk about.

Report •

June 23, 2010 at 10:37:30

Insomniac at large

Report •

June 23, 2010 at 21:42:27
What about piping to:

findstr /r "^OK.*[A-Z]:"

It should at least lower the chance of a failure.

Report •

June 24, 2010 at 04:06:19
Judago, I don't understand what you mean. Could you give a
small explanaition where I would put that? Do you mean I
should place it in my for loop? Thanks

Report •

June 24, 2010 at 17:17:29
Yep, inside the loop.

in (' net use ^| findstr /r "^OK.*[A-Z]:" ') do

Report •

June 28, 2010 at 04:08:13
Judago, I haven't had much time to test this. It didn't work when I tried it. I will spend more time and try find out why it didn't work.
Thanks for your suggestion though.

Report •

Ask Question