Batch file to show Network drives

  • Thread starter Thread starter joshboski
  • Start date Start date
Timo Salmi wrote:
> Pegasus (MVP) <I.can@fly.com.oz> wrote:
>> This line works under WinXP:
>> fsutil fsinfo drives|more

>
> One traditional, UNIX-flavored way of getting rid of nul characters in a
> string is using a TR port
>
> fsutil fsinfo drives|tr -d \000
>
> Or SED
> fsutil fsinfo drives|sed -e "s/\x00/ /g"
>
> But indeed, fortunately, the more trick does the same as can be readily
> seen with any hex lister. Also, as was recently discussed in another
> connection, the more conveniently adds a 0D 0A pair at the end of the
> output, if it is missing. Well, in this case it is not.
>
> Not that fsutil fsinfo is the only way of listing ones active drives!
> The code below will give a list of devices that are _ready_
>
> @echo off & setlocal enableextensions enabledelayedexpansion
> for %%d in (a: b: c: d: e: f: g: h: i: j: k: l: m: n:
> o: p: q: r: s: t: u: v: w: x: y: z:) do (
> dir %%d\ > nul 2>&1
> if !errorlevel! EQU 0 echo %%d
> )
> endlocal & goto :EOF
>
> E.g. one might get
> C:\_D\TEST>cmdfaq
> c:
> d:
> e:
>
> All the best, Timo
>

Mmm I see Ms have dropped the hoary "Abort Retry Ignore" message
 
The following works on 2003 and Vista but is really slow (at least
on 2003) when it encounters a disconnected network drive letter that *IS*
mapped:

ALL ONE LINE FOLLOWING:

for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
exist %%a:\lpt1 @fsutil fsinfo drivetype %%a:


This takes advantage of the pseudo file "LPT1" which has been
around since early DOS to prevent confusion with file names
that are the same as the Print device name (IIRC).

"if exist c:\lpt1" is TRUE if c:\ exists otherwise it is false.

I like the " | more +1 /S" best I think for 2003.

I thought I found a trick with FindStr that would convert the nulls
to dots, but it was just cosmetic on the screen and the pipe didn't
do that.

The following LOOKS good on the screen but isn't useful as far
as I can tell:

fsutil fsinfo drives | findstr \\

Is there anyway to get a NULL into "delims="????

> "Herb Martin" <news@learnquick.com> wrote in message
> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>
> Ok, based on what someone (sorry) wrote in another message this
> thread I finally figured out that XP/2003 were using NULLS instead
> of spaces and so now my Perl version works on both all OSes:
>
> Following is all one line for a batch file but works if pasted or typed in
> directly:
>
> @fsutil fsinfo drives | perl -n -e "@a=split /\s|\00/ foreach (@a) {next
> unless s/\\//print `fsutil fsinfo drivetype $_`}"
>
>
> OK, this works on 2003 using the | more trick (with +1 /S for efficiency):
>
>
> @for /f %%a in ('fsutil fsinfo drives ^| more +1 /S') do @fsutil fsinfo
> drivetype %%a
>
>
> The MORE trick is problematic however if your command line is SMALLER
> than the list of drives -- probably not a frequent issue but it will be an
> issue
> on rare occasions for some people.
>
> I also admit that I cannot figure out Dean's unicode trick (quickly
> enough)
> to extract and use it here.
>
> --
> Herb
>
>> I have been meaning to ask advice or figure the following out myself
>> so I will just post my solution and describe where it has problems.
>>
>> The following code WORKS on Vista, but not on 2003, nor on
>> XP if I recall the latter correctly.
>>
>> Following is all one line (in a batch file):
>>
>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do @for
>> %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>> drivetype %%A

>
>
>> =======================
>> Ugly but it works on Vista like this:
>>
>> A: - Remote/Network Drive
>> C: - Fixed Drive
>> D: - Fixed Drive
>> E: - Fixed Drive
>> F: - CD-ROM Drive
>> G: - CD-ROM Drive
>> H: - CD-ROM Drive
>> J: - Remote/Network Drive
>> O: - Remote/Network Drive
>> P: - Remote/Network Drive
>> Q: - Remote/Network Drive
>> R: - CD-ROM Drive
>> S: - Remote/Network Drive
>> T: - Remote/Network Drive
>> U: - Remote/Network Drive
>> W: - Remote/Network Drive
>> X: - Remote/Network Drive
>> Y: - Remote/Network Drive
>> Z: - Remote/Network Drive
>>
>>
>>

>
>
 
Re: Batch file to show Network drives -- simple methods for XP/2003/Vista work now

Ok (after obsessing a bit) this work on (at least) XP/2003:

[Following is all one line for a batch file: drives.cmd]

@for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @fsutil fsinfo
drivetype %%a


And this version works on (at least) Vista:
[Following is all one line for a batch file: drives.cmd]

@for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do @for %%A
in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s
%%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo drivetype %%A


Oddly enought the XP/2003 is not less awkward.

Output looks like this (with fix width font so it lines up there):

A: - Remote/Network Drive
C: - Fixed Drive
D: - Fixed Drive
E: - Fixed Drive
F: - CD-ROM Drive
G: - CD-ROM Drive
H: - CD-ROM Drive
J: - Remote/Network Drive
O: - Remote/Network Drive
P: - Remote/Network Drive
Q: - Remote/Network Drive
R: - CD-ROM Drive
S: - Remote/Network Drive
T: - Remote/Network Drive
U: - Remote/Network Drive
V: - Remote/Network Drive
W: - Remote/Network Drive
X: - Remote/Network Drive
Y: - Remote/Network Drive
Z: - Remote/Network Drive



"Herb Martin" <news@learnquick.com> wrote in message
news:%23ufNxshxIHA.3968@TK2MSFTNGP04.phx.gbl...
>
> The following works on 2003 and Vista but is really slow (at least
> on 2003) when it encounters a disconnected network drive letter that *IS*
> mapped:
>
> ALL ONE LINE FOLLOWING:
>
> for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
> exist %%a:\lpt1 @fsutil fsinfo drivetype %%a:
>
>
> This takes advantage of the pseudo file "LPT1" which has been
> around since early DOS to prevent confusion with file names
> that are the same as the Print device name (IIRC).
>
> "if exist c:\lpt1" is TRUE if c:\ exists otherwise it is false.
>
> I like the " | more +1 /S" best I think for 2003.
>
> I thought I found a trick with FindStr that would convert the nulls
> to dots, but it was just cosmetic on the screen and the pipe didn't
> do that.
>
> The following LOOKS good on the screen but isn't useful as far
> as I can tell:
>
> fsutil fsinfo drives | findstr \\
>
> Is there anyway to get a NULL into "delims="????
>
>> "Herb Martin" <news@learnquick.com> wrote in message
>> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>
>> Ok, based on what someone (sorry) wrote in another message this
>> thread I finally figured out that XP/2003 were using NULLS instead
>> of spaces and so now my Perl version works on both all OSes:
>>
>> Following is all one line for a batch file but works if pasted or typed
>> in directly:
>>
>> @fsutil fsinfo drives | perl -n -e "@a=split /\s|\00/ foreach (@a) {next
>> unless s/\\//print `fsutil fsinfo drivetype $_`}"
>>
>>
>> OK, this works on 2003 using the | more trick (with +1 /S for
>> efficiency):
>>
>>
>> @for /f %%a in ('fsutil fsinfo drives ^| more +1 /S') do @fsutil fsinfo
>> drivetype %%a
>>
>>
>> The MORE trick is problematic however if your command line is SMALLER
>> than the list of drives -- probably not a frequent issue but it will be
>> an issue
>> on rare occasions for some people.
>>
>> I also admit that I cannot figure out Dean's unicode trick (quickly
>> enough)
>> to extract and use it here.
>>
>> --
>> Herb
>>
>>> I have been meaning to ask advice or figure the following out myself
>>> so I will just post my solution and describe where it has problems.
>>>
>>> The following code WORKS on Vista, but not on 2003, nor on
>>> XP if I recall the latter correctly.
>>>
>>> Following is all one line (in a batch file):
>>>
>>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do @for
>>> %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>>> drivetype %%A

>>
>>
>>> =======================
>>> Ugly but it works on Vista like this:
>>>
>>> A: - Remote/Network Drive
>>> C: - Fixed Drive
>>> D: - Fixed Drive
>>> E: - Fixed Drive
>>> F: - CD-ROM Drive
>>> G: - CD-ROM Drive
>>> H: - CD-ROM Drive
>>> J: - Remote/Network Drive
>>> O: - Remote/Network Drive
>>> P: - Remote/Network Drive
>>> Q: - Remote/Network Drive
>>> R: - CD-ROM Drive
>>> S: - Remote/Network Drive
>>> T: - Remote/Network Drive
>>> U: - Remote/Network Drive
>>> W: - Remote/Network Drive
>>> X: - Remote/Network Drive
>>> Y: - Remote/Network Drive
>>> Z: - Remote/Network Drive
>>>
>>>
>>>

>>
>>

>
>
 
It's always strange to me just how much pleasure I seem to derive from
working in this (let's face it) old & crappy little shell ... but,
seemingly like the rest of you, I'm quite happy doing so and will
readily jump on the 'let's see how many alternatives there are'
band-wagon whilst striving for the apparent golden-egg of batch syntax:
that ever elusive 'let's make it a one-liner.' Anyway, I came up with
this improvement on my original syntax, it too limits the number of
iterations resulting from the for loop to only those necessary (note
that it's a one-liner well, sorta) -

fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Herb Martin" <news@learnquick.com> wrote in message
news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>
> "Bob I" <birelan@yahoo.com> wrote in message
> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>> See "net use" and "If exist" in Windows Help and support. Also there
>> is a cmd prompt group that has some pretty sharp folks(cross posting
>> this)
>>
>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>
>> joshboski wrote:
>>
>>> I am currently trying to write a batch file that will delete a list
>>> of
>>> files from all of my network drives. The problem I am having is
>>> getting the network drives. I am on a rather large network, and I
>>> would like this to run on several different computers that may be
>>> connected to different drives.

>
> I have been meaning to ask advice or figure the following out myself
> so I will just post my solution and describe where it has problems.
>
> The following code WORKS on Vista, but not on 2003, nor on
> XP if I recall the latter correctly.
>
> Following is all one line (in a batch file):
>
> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
> drivetype %%A
>
>
> =======================
> Ugly but it works on Vista like this:
>
> A: - Remote/Network Drive
> C: - Fixed Drive
> D: - Fixed Drive
> E: - Fixed Drive
> F: - CD-ROM Drive
> G: - CD-ROM Drive
> H: - CD-ROM Drive
> J: - Remote/Network Drive
> O: - Remote/Network Drive
> P: - Remote/Network Drive
> Q: - Remote/Network Drive
> R: - CD-ROM Drive
> S: - Remote/Network Drive
> T: - Remote/Network Drive
> U: - Remote/Network Drive
> W: - Remote/Network Drive
> X: - Remote/Network Drive
> Y: - Remote/Network Drive
> Z: - Remote/Network Drive
>
>
>
 
On Wed, 4 Jun 2008 09:14:38 -0400, "Dean Wells \(MVP\)"
<dwells@maskmsetechnology.com> wrote:

>It's always strange to me just how much pleasure I seem to derive from
>working in this (let's face it) old & crappy little shell ... but,
>seemingly like the rest of you, I'm quite happy doing so and will
>readily jump on the 'let's see how many alternatives there are'
>band-wagon whilst striving for the apparent golden-egg of batch syntax:
>that ever elusive 'let's make it a one-liner.'


Here's more conventional syntax in my contribution after following this
thread:


@echo off
for /f "delims=" %%a in ('fsutil fsinfo drives^|more') do call :next "%%a"
goto :EOF
:next
set "var=%~1"
set "var=%var:~-3,2%"
fsutil fsinfo drivetype %var%
shift
if not %1.==. goto :next
 
Hi, I think there's an error in there, at least from Vista's perspective
.... this is the result from Vista's shell <paste> -

C:\>foo

C:\>rem @echo off

C:\>for /F "delims=" %a in ('fsutil fsinfo drives |more') do call :next
"%a"

C:\>call :next "Drives: C:\ D:\ E:\ "

C:\>set "var=Drives: C:\ D:\ E:\ "

C:\>set "var=:\"

C:\>fsutil fsinfo drivetype :\
:\ - No such Root Directory

C:\>shift

C:\>if not . == . goto :next

C:\>goto :EOF

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"foxidrive" <gotcha@woohoo.invalid> wrote in message
news:4vfd44l75et0ks3p1ses92n0t5b7hicgkp@4ax.com...
> On Wed, 4 Jun 2008 09:14:38 -0400, "Dean Wells \(MVP\)"
> <dwells@maskmsetechnology.com> wrote:
>
>>It's always strange to me just how much pleasure I seem to derive from
>>working in this (let's face it) old & crappy little shell ... but,
>>seemingly like the rest of you, I'm quite happy doing so and will
>>readily jump on the 'let's see how many alternatives there are'
>>band-wagon whilst striving for the apparent golden-egg of batch
>>syntax:
>>that ever elusive 'let's make it a one-liner.'

>
> Here's more conventional syntax in my contribution after following
> this
> thread:
>
>
> @echo off
> for /f "delims=" %%a in ('fsutil fsinfo drives^|more') do call :next
> "%%a"
> goto :EOF
> :next
> set "var=%~1"
> set "var=%var:~-3,2%"
> fsutil fsinfo drivetype %var%
> shift
> if not %1.==. goto :next
>
>
>
 
On Wed, 4 Jun 2008 12:45:20 -0400, "Dean Wells \(MVP\)"
<dwells@maskmsetechnology.com> wrote:

>Hi, I think there's an error in there, at least from Vista's perspective
>... this is the result from Vista's shell <paste> -


Nods.

It works under XP pro - I don't have Vista to test with.

>C:\>foo
>
>C:\>rem @echo off
>
>C:\>for /F "delims=" %a in ('fsutil fsinfo drives |more') do call :next
>"%a"
>
>C:\>call :next "Drives: C:\ D:\ E:\ "
 
"foxidrive" <gotcha@woohoo.invalid> wrote in message
news:srnd449nnacjl4hfbheqcuar107o5gonr8@4ax.com...
> On Wed, 4 Jun 2008 12:45:20 -0400, "Dean Wells \(MVP\)"
> <dwells@maskmsetechnology.com> wrote:
>
>>Hi, I think there's an error in there, at least from Vista's perspective
>>... this is the result from Vista's shell <paste> -

>
> Nods.
>
> It works under XP pro - I don't have Vista to test with.



I have some extra *personal* criteria:

General principle: Runs on anybody's machine (where it makes sense)

No temp files if they can be avoided
No VBScript if it can be avoided -- once necessary go to Perl or Ruby
(But ONLY Perl is on ALL of my machines though Ruby is gaining
ground)
No external utilities if they can be avoided, Support tools not as bad as
other
stuff, Reskit, then UnxUtils, and some of my own personal tools, then
Cygwin

Prefer not to use environment variables, but this is not a rule
Once line when possible but don't get crazy
Working as a DosKey macros is desirable
(Although I use this for starting externa programs that aren't on the
path too)
Preferably works on all versions of the OS (where the program makes sense)

If it is too difficult for those rules then use Perl, Ruby, or a custom C/C#
program

So repeating my best efforts from last night:

[Following is all one line for a batch file: drives.cmd]

@for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @fsutil fsinfo
drivetype %%a


And this version works on (at least) Vista:
[Following is all one line for a batch file: drives.cmd]

@for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do @for %%A
in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s
%%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo drivetype %%A


Oddly enought the XP/2003 is not less awkward.

Output looks like this (with fix width font so it lines up there):

A: - Remote/Network Drive
C: - Fixed Drive
D: - Fixed Drive
E: - Fixed Drive
F: - CD-ROM Drive
G: - CD-ROM Drive
H: - CD-ROM Drive
J: - Remote/Network Drive
O: - Remote/Network Drive
P: - Remote/Network Drive
Q: - Remote/Network Drive
R: - CD-ROM Drive
S: - Remote/Network Drive
T: - Remote/Network Drive
U: - Remote/Network Drive
V: - Remote/Network Drive
W: - Remote/Network Drive
X: - Remote/Network Drive
Y: - Remote/Network Drive
Z: - Remote/Network Drive
 
"Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
news:%23j5g1TkxIHA.1772@TK2MSFTNGP03.phx.gbl...
> It's always strange to me just how much pleasure I seem to derive from
> working in this (let's face it) old & crappy little shell ... but,
> seemingly like the rest of you, I'm quite happy doing so and will readily
> jump on the 'let's see how many alternatives there are' band-wagon whilst
> striving for the apparent golden-egg of batch syntax: that ever elusive
> 'let's make it a one-liner.' Anyway, I came up with this improvement on
> my original syntax, it too limits the number of iterations resulting from
> the for loop to only those necessary (note that it's a one-liner well,
> sorta) -
>
> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c type
> "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
> drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul


Cool. I never did understand (or really isolate) your Unicode trick
from that big batch file -- the one to remove the NULLS.

I ended up using a pipe to find on XP -- after using more as the
next best thing but admitting that more will fail (or at least ask for
key to continue) if there are more drives than screen lines.)

This last isn't a giant deal as I keep my screen MUCH bigger than
the maximum (?) 26 drive letters but not everyone does all of the
time.


> "Herb Martin" <news@learnquick.com> wrote in message
> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>
>> "Bob I" <birelan@yahoo.com> wrote in message
>> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>>> See "net use" and "If exist" in Windows Help and support. Also there
>>> is a cmd prompt group that has some pretty sharp folks(cross posting
>>> this)
>>>
>>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>>
>>> joshboski wrote:
>>>
>>>> I am currently trying to write a batch file that will delete a list
>>>> of
>>>> files from all of my network drives. The problem I am having is
>>>> getting the network drives. I am on a rather large network, and I
>>>> would like this to run on several different computers that may be
>>>> connected to different drives.

>>
>> I have been meaning to ask advice or figure the following out myself
>> so I will just post my solution and describe where it has problems.
>>
>> The following code WORKS on Vista, but not on 2003, nor on
>> XP if I recall the latter correctly.
>>
>> Following is all one line (in a batch file):
>>
>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
>> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>> drivetype %%A
>>
>>
>> =======================
>> Ugly but it works on Vista like this:
>>
>> A: - Remote/Network Drive
>> C: - Fixed Drive
>> D: - Fixed Drive
>> E: - Fixed Drive
>> F: - CD-ROM Drive
>> G: - CD-ROM Drive
>> H: - CD-ROM Drive
>> J: - Remote/Network Drive
>> O: - Remote/Network Drive
>> P: - Remote/Network Drive
>> Q: - Remote/Network Drive
>> R: - CD-ROM Drive
>> S: - Remote/Network Drive
>> T: - Remote/Network Drive
>> U: - Remote/Network Drive
>> W: - Remote/Network Drive
>> X: - Remote/Network Drive
>> Y: - Remote/Network Drive
>> Z: - Remote/Network Drive
>>
>>
>>

>
>
>
 
Nod, I thought of the same thing re: the letter-depth but figured it's
so nigh-on moot for the same reasons ...

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Herb Martin" <news@learnquick.com> wrote in message
news:eW$cX6nxIHA.4492@TK2MSFTNGP02.phx.gbl...
>
> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
> news:%23j5g1TkxIHA.1772@TK2MSFTNGP03.phx.gbl...
>> It's always strange to me just how much pleasure I seem to derive
>> from working in this (let's face it) old & crappy little shell ...
>> but, seemingly like the rest of you, I'm quite happy doing so and
>> will readily jump on the 'let's see how many alternatives there are'
>> band-wagon whilst striving for the apparent golden-egg of batch
>> syntax: that ever elusive 'let's make it a one-liner.' Anyway, I
>> came up with this improvement on my original syntax, it too limits
>> the number of iterations resulting from the for loop to only those
>> necessary (note that it's a one-liner well, sorta) -
>>
>> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
>> type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil
>> fsinfo drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul

>
> Cool. I never did understand (or really isolate) your Unicode trick
> from that big batch file -- the one to remove the NULLS.
>
> I ended up using a pipe to find on XP -- after using more as the
> next best thing but admitting that more will fail (or at least ask for
> key to continue) if there are more drives than screen lines.)
>
> This last isn't a giant deal as I keep my screen MUCH bigger than
> the maximum (?) 26 drive letters but not everyone does all of the
> time.
>
>
>> "Herb Martin" <news@learnquick.com> wrote in message
>> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>>
>>> "Bob I" <birelan@yahoo.com> wrote in message
>>> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>>>> See "net use" and "If exist" in Windows Help and support. Also
>>>> there
>>>> is a cmd prompt group that has some pretty sharp folks(cross
>>>> posting
>>>> this)
>>>>
>>>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>>>
>>>> joshboski wrote:
>>>>
>>>>> I am currently trying to write a batch file that will delete a
>>>>> list
>>>>> of
>>>>> files from all of my network drives. The problem I am having is
>>>>> getting the network drives. I am on a rather large network, and I
>>>>> would like this to run on several different computers that may be
>>>>> connected to different drives.
>>>
>>> I have been meaning to ask advice or figure the following out myself
>>> so I will just post my solution and describe where it has problems.
>>>
>>> The following code WORKS on Vista, but not on 2003, nor on
>>> XP if I recall the latter correctly.
>>>
>>> Following is all one line (in a batch file):
>>>
>>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
>>> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>>> drivetype %%A
>>>
>>>
>>> =======================
>>> Ugly but it works on Vista like this:
>>>
>>> A: - Remote/Network Drive
>>> C: - Fixed Drive
>>> D: - Fixed Drive
>>> E: - Fixed Drive
>>> F: - CD-ROM Drive
>>> G: - CD-ROM Drive
>>> H: - CD-ROM Drive
>>> J: - Remote/Network Drive
>>> O: - Remote/Network Drive
>>> P: - Remote/Network Drive
>>> Q: - Remote/Network Drive
>>> R: - CD-ROM Drive
>>> S: - Remote/Network Drive
>>> T: - Remote/Network Drive
>>> U: - Remote/Network Drive
>>> W: - Remote/Network Drive
>>> X: - Remote/Network Drive
>>> Y: - Remote/Network Drive
>>> Z: - Remote/Network Drive
>>>
>>>
>>>

>>
>>
>>

>
>
 
Re: Batch file to show Network drives -- simple methods for XP/2003/Vistawork now

Herb Martin wrote:
> Ok (after obsessing a bit) this work on (at least) XP/2003:
>
> [Following is all one line for a batch file: drives.cmd]
>
> @for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @fsutil fsinfo
> drivetype %%a
>
>

well for me (XP Pro) it also gives a spurious Drives line:

Drives: - No such Root Directory
C:\ - Fixed Drive
D:\ - Fixed Drive
E:\ - Fixed Drive
Q:\ - CD-ROM Drive

where I have an "A" floppy drive with no disk present:

C:\WINDOWS>fsutil fsinfo drives

Drives: A:\ C:\ D:\ E:\ Q:\

C:\WINDOWS>
 
Re: Batch file to show Network drives -- simple methods for XP/2003/Vista work now

"Esra Sdrawkcab" <admin@127.0.0.1> wrote in message
news:oDD1k.3371$E41.3163@text.news.virginmedia.com...
> Herb Martin wrote:
>> Ok (after obsessing a bit) this work on (at least) XP/2003:
>>
>> [Following is all one line for a batch file: drives.cmd]
>>
>> @for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @fsutil fsinfo
>> drivetype %%a
>>
>>

> well for me (XP Pro) it also gives a spurious Drives line:
>
> Drives: - No such Root Directory
> C:\ - Fixed Drive
> D:\ - Fixed Drive
> E:\ - Fixed Drive
> Q:\ - CD-ROM Drive
>
> where I have an "A" floppy drive with no disk present:
>
> C:\WINDOWS>fsutil fsinfo drives
>
> Drives: A:\ C:\ D:\ E:\ Q:\
>
> C:\WINDOWS>


You can "if test" those out if you need to do so.

[Following is all one line for batch file]
@for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @if not
"%%a"=="Drives:" fsutil fsinfo drivetype %%a

I prefer this method to using the "skip=1" in the "for"-loop
options since apparently 2003 has no problem and only
XP shows this.

I had seen no problem so didn't bother -- turns out I
tested the "XP" version mostly on 2003 and didn't see
that XP and 2003 were (slightly) different.

Go figure.

Heck, I don't REALLY even know why the "find" on a "slash"
works but have been assuming that it is just using the Nulls
to spit out separate lines.

I didn't "think this through" to get to this solution but was semi-randomly
trying FindStr, Find, type, copy looking for anything that would turn
the nulls into something else (spaces.)
 
"Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
news:eQRnffoxIHA.1768@TK2MSFTNGP03.phx.gbl...
> Nod, I thought of the same thing re: the letter-depth but figured it's so
> nigh-on moot for the same reasons ...


That's why I did like the pipe to find "\".

Here's the current one that doesn't mess up with "Drives:"
on XP (I hadn't notice the error until Esra pointed that
out (I was testing under 2003 mostly and who would have
thought that XP and 2003 which both WORK basicly
would be different in a new way?)

[Following is all one line for a batch file]

@for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @if not
"%%a"=="Drives:" fsutil fsinfo drivetype %%a


I didn't use "For" option SKIP=1 because it would be different
for XP vs. 2003.

> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
>
> "Herb Martin" <news@learnquick.com> wrote in message
> news:eW$cX6nxIHA.4492@TK2MSFTNGP02.phx.gbl...
>>
>> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
>> news:%23j5g1TkxIHA.1772@TK2MSFTNGP03.phx.gbl...
>>> It's always strange to me just how much pleasure I seem to derive from
>>> working in this (let's face it) old & crappy little shell ... but,
>>> seemingly like the rest of you, I'm quite happy doing so and will
>>> readily jump on the 'let's see how many alternatives there are'
>>> band-wagon whilst striving for the apparent golden-egg of batch syntax:
>>> that ever elusive 'let's make it a one-liner.' Anyway, I came up with
>>> this improvement on my original syntax, it too limits the number of
>>> iterations resulting from the for loop to only those necessary (note
>>> that it's a one-liner well, sorta) -
>>>
>>> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
>>> type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
>>> drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul

>>
>> Cool. I never did understand (or really isolate) your Unicode trick
>> from that big batch file -- the one to remove the NULLS.
>>
>> I ended up using a pipe to find on XP -- after using more as the
>> next best thing but admitting that more will fail (or at least ask for
>> key to continue) if there are more drives than screen lines.)
>>
>> This last isn't a giant deal as I keep my screen MUCH bigger than
>> the maximum (?) 26 drive letters but not everyone does all of the
>> time.
>>
>>
>>> "Herb Martin" <news@learnquick.com> wrote in message
>>> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>>>
>>>> "Bob I" <birelan@yahoo.com> wrote in message
>>>> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>>>>> See "net use" and "If exist" in Windows Help and support. Also there
>>>>> is a cmd prompt group that has some pretty sharp folks(cross posting
>>>>> this)
>>>>>
>>>>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>>>>
>>>>> joshboski wrote:
>>>>>
>>>>>> I am currently trying to write a batch file that will delete a list
>>>>>> of
>>>>>> files from all of my network drives. The problem I am having is
>>>>>> getting the network drives. I am on a rather large network, and I
>>>>>> would like this to run on several different computers that may be
>>>>>> connected to different drives.
>>>>
>>>> I have been meaning to ask advice or figure the following out myself
>>>> so I will just post my solution and describe where it has problems.
>>>>
>>>> The following code WORKS on Vista, but not on 2003, nor on
>>>> XP if I recall the latter correctly.
>>>>
>>>> Following is all one line (in a batch file):
>>>>
>>>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
>>>> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>>>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>>>> drivetype %%A
>>>>
>>>>
>>>> =======================
>>>> Ugly but it works on Vista like this:
>>>>
>>>> A: - Remote/Network Drive
>>>> C: - Fixed Drive
>>>> D: - Fixed Drive
>>>> E: - Fixed Drive
>>>> F: - CD-ROM Drive
>>>> G: - CD-ROM Drive
>>>> H: - CD-ROM Drive
>>>> J: - Remote/Network Drive
>>>> O: - Remote/Network Drive
>>>> P: - Remote/Network Drive
>>>> Q: - Remote/Network Drive
>>>> R: - CD-ROM Drive
>>>> S: - Remote/Network Drive
>>>> T: - Remote/Network Drive
>>>> U: - Remote/Network Drive
>>>> W: - Remote/Network Drive
>>>> X: - Remote/Network Drive
>>>> Y: - Remote/Network Drive
>>>> Z: - Remote/Network Drive
>>>>
>>>>
>>>>
>>>
>>>
>>>

>>
>>

>
>
 
Sadly, that still doesn't work under Vista ... the one-liner I posted
earlier seems to work across the board ... or perhaps I missed
something? -->

fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul

--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


"Herb Martin" <news@learnquick.com> wrote in message
news:Ogx61KpxIHA.1980@TK2MSFTNGP02.phx.gbl...
>
> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
> news:eQRnffoxIHA.1768@TK2MSFTNGP03.phx.gbl...
>> Nod, I thought of the same thing re: the letter-depth but figured
>> it's so nigh-on moot for the same reasons ...

>
> That's why I did like the pipe to find "\".
>
> Here's the current one that doesn't mess up with "Drives:"
> on XP (I hadn't notice the error until Esra pointed that
> out (I was testing under 2003 mostly and who would have
> thought that XP and 2003 which both WORK basicly
> would be different in a new way?)
>
> [Following is all one line for a batch file]
>
> @for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @if not
> "%%a"=="Drives:" fsutil fsinfo drivetype %%a
>
>
> I didn't use "For" option SKIP=1 because it would be different
> for XP vs. 2003.
>
>> --
>> Dean Wells [MVP / Directory Services]
>> MSEtechnology
>> [[ Please respond to the Newsgroup only regarding posts ]]
>> R e m o v e t h e m a s k t o s e n d e m a i l
>>
>>
>> "Herb Martin" <news@learnquick.com> wrote in message
>> news:eW$cX6nxIHA.4492@TK2MSFTNGP02.phx.gbl...
>>>
>>> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
>>> news:%23j5g1TkxIHA.1772@TK2MSFTNGP03.phx.gbl...
>>>> It's always strange to me just how much pleasure I seem to derive
>>>> from working in this (let's face it) old & crappy little shell ...
>>>> but, seemingly like the rest of you, I'm quite happy doing so and
>>>> will readily jump on the 'let's see how many alternatives there
>>>> are' band-wagon whilst striving for the apparent golden-egg of
>>>> batch syntax: that ever elusive 'let's make it a one-liner.'
>>>> Anyway, I came up with this improvement on my original syntax, it
>>>> too limits the number of iterations resulting from the for loop to
>>>> only those necessary (note that it's a one-liner well, sorta) -
>>>>
>>>> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u
>>>> /c type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do
>>>> fsutil fsinfo drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul
>>>
>>> Cool. I never did understand (or really isolate) your Unicode trick
>>> from that big batch file -- the one to remove the NULLS.
>>>
>>> I ended up using a pipe to find on XP -- after using more as the
>>> next best thing but admitting that more will fail (or at least ask
>>> for
>>> key to continue) if there are more drives than screen lines.)
>>>
>>> This last isn't a giant deal as I keep my screen MUCH bigger than
>>> the maximum (?) 26 drive letters but not everyone does all of the
>>> time.
>>>
>>>
>>>> "Herb Martin" <news@learnquick.com> wrote in message
>>>> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>>>>
>>>>> "Bob I" <birelan@yahoo.com> wrote in message
>>>>> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>>>>>> See "net use" and "If exist" in Windows Help and support. Also
>>>>>> there
>>>>>> is a cmd prompt group that has some pretty sharp folks(cross
>>>>>> posting
>>>>>> this)
>>>>>>
>>>>>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>>>>>
>>>>>> joshboski wrote:
>>>>>>
>>>>>>> I am currently trying to write a batch file that will delete a
>>>>>>> list
>>>>>>> of
>>>>>>> files from all of my network drives. The problem I am having is
>>>>>>> getting the network drives. I am on a rather large network, and
>>>>>>> I
>>>>>>> would like this to run on several different computers that may
>>>>>>> be
>>>>>>> connected to different drives.
>>>>>
>>>>> I have been meaning to ask advice or figure the following out
>>>>> myself
>>>>> so I will just post my solution and describe where it has
>>>>> problems.
>>>>>
>>>>> The following code WORKS on Vista, but not on 2003, nor on
>>>>> XP if I recall the latter correctly.
>>>>>
>>>>> Following is all one line (in a batch file):
>>>>>
>>>>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
>>>>> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>>>>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>>>>> drivetype %%A
>>>>>
>>>>>
>>>>> =======================
>>>>> Ugly but it works on Vista like this:
>>>>>
>>>>> A: - Remote/Network Drive
>>>>> C: - Fixed Drive
>>>>> D: - Fixed Drive
>>>>> E: - Fixed Drive
>>>>> F: - CD-ROM Drive
>>>>> G: - CD-ROM Drive
>>>>> H: - CD-ROM Drive
>>>>> J: - Remote/Network Drive
>>>>> O: - Remote/Network Drive
>>>>> P: - Remote/Network Drive
>>>>> Q: - Remote/Network Drive
>>>>> R: - CD-ROM Drive
>>>>> S: - Remote/Network Drive
>>>>> T: - Remote/Network Drive
>>>>> U: - Remote/Network Drive
>>>>> W: - Remote/Network Drive
>>>>> X: - Remote/Network Drive
>>>>> Y: - Remote/Network Drive
>>>>> Z: - Remote/Network Drive
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>
 
"Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
news:OMizjFqxIHA.2384@TK2MSFTNGP02.phx.gbl...
> Sadly, that still doesn't work under Vista ... the one-liner I posted
> earlier seems to work across the board ... or perhaps I missed
> something? -->
>
> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
> type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
> drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul


Sorry, I didn't repost my Vista version in that last messages but
had done so elsewhere this thread. It had been working all along.

@for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do @for %%A
in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s
%%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo drivetype %%A

I have been using this for about a year on Vista.

No temp files.

I just use an OS check to decide which of the two to use,
as I prefer that to temp files and the (highly technical) issue
with more etc.

> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
>
> "Herb Martin" <news@learnquick.com> wrote in message
> news:Ogx61KpxIHA.1980@TK2MSFTNGP02.phx.gbl...
>>
>> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
>> news:eQRnffoxIHA.1768@TK2MSFTNGP03.phx.gbl...
>>> Nod, I thought of the same thing re: the letter-depth but figured it's
>>> so nigh-on moot for the same reasons ...

>>
>> That's why I did like the pipe to find "\".
>>
>> Here's the current one that doesn't mess up with "Drives:"
>> on XP (I hadn't notice the error until Esra pointed that
>> out (I was testing under 2003 mostly and who would have
>> thought that XP and 2003 which both WORK basicly
>> would be different in a new way?)
>>
>> [Following is all one line for a batch file]
>>
>> @for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @if not
>> "%%a"=="Drives:" fsutil fsinfo drivetype %%a
>>
>>
>> I didn't use "For" option SKIP=1 because it would be different
>> for XP vs. 2003.
>>
>>> --
>>> Dean Wells [MVP / Directory Services]
>>> MSEtechnology
>>> [[ Please respond to the Newsgroup only regarding posts ]]
>>> R e m o v e t h e m a s k t o s e n d e m a i l
>>>
>>>
>>> "Herb Martin" <news@learnquick.com> wrote in message
>>> news:eW$cX6nxIHA.4492@TK2MSFTNGP02.phx.gbl...
>>>>
>>>> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
>>>> news:%23j5g1TkxIHA.1772@TK2MSFTNGP03.phx.gbl...
>>>>> It's always strange to me just how much pleasure I seem to derive from
>>>>> working in this (let's face it) old & crappy little shell ... but,
>>>>> seemingly like the rest of you, I'm quite happy doing so and will
>>>>> readily jump on the 'let's see how many alternatives there are'
>>>>> band-wagon whilst striving for the apparent golden-egg of batch
>>>>> syntax: that ever elusive 'let's make it a one-liner.' Anyway, I came
>>>>> up with this improvement on my original syntax, it too limits the
>>>>> number of iterations resulting from the for loop to only those
>>>>> necessary (note that it's a one-liner well, sorta) -
>>>>>
>>>>> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
>>>>> type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil
>>>>> fsinfo drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul
>>>>
>>>> Cool. I never did understand (or really isolate) your Unicode trick
>>>> from that big batch file -- the one to remove the NULLS.
>>>>
>>>> I ended up using a pipe to find on XP -- after using more as the
>>>> next best thing but admitting that more will fail (or at least ask for
>>>> key to continue) if there are more drives than screen lines.)
>>>>
>>>> This last isn't a giant deal as I keep my screen MUCH bigger than
>>>> the maximum (?) 26 drive letters but not everyone does all of the
>>>> time.
>>>>
>>>>
>>>>> "Herb Martin" <news@learnquick.com> wrote in message
>>>>> news:OSAywudxIHA.2208@TK2MSFTNGP04.phx.gbl...
>>>>>>
>>>>>> "Bob I" <birelan@yahoo.com> wrote in message
>>>>>> news:er75LzXxIHA.5472@TK2MSFTNGP06.phx.gbl...
>>>>>>> See "net use" and "If exist" in Windows Help and support. Also there
>>>>>>> is a cmd prompt group that has some pretty sharp folks(cross posting
>>>>>>> this)
>>>>>>>
>>>>>>> news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
>>>>>>>
>>>>>>> joshboski wrote:
>>>>>>>
>>>>>>>> I am currently trying to write a batch file that will delete a list
>>>>>>>> of
>>>>>>>> files from all of my network drives. The problem I am having is
>>>>>>>> getting the network drives. I am on a rather large network, and I
>>>>>>>> would like this to run on several different computers that may be
>>>>>>>> connected to different drives.
>>>>>>
>>>>>> I have been meaning to ask advice or figure the following out myself
>>>>>> so I will just post my solution and describe where it has problems.
>>>>>>
>>>>>> The following code WORKS on Vista, but not on 2003, nor on
>>>>>> XP if I recall the latter correctly.
>>>>>>
>>>>>> Following is all one line (in a batch file):
>>>>>>
>>>>>> @for /f "tokens=1-26 delims=\ " %%a in ('fsutil fsinfo drives') do
>>>>>> @for %%A in (%%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
>>>>>> %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z) do @fsutil fsinfo
>>>>>> drivetype %%A
>>>>>>
>>>>>>
>>>>>> =======================
>>>>>> Ugly but it works on Vista like this:
>>>>>>
>>>>>> A: - Remote/Network Drive
>>>>>> C: - Fixed Drive
>>>>>> D: - Fixed Drive
>>>>>> E: - Fixed Drive
>>>>>> F: - CD-ROM Drive
>>>>>> G: - CD-ROM Drive
>>>>>> H: - CD-ROM Drive
>>>>>> J: - Remote/Network Drive
>>>>>> O: - Remote/Network Drive
>>>>>> P: - Remote/Network Drive
>>>>>> Q: - Remote/Network Drive
>>>>>> R: - CD-ROM Drive
>>>>>> S: - Remote/Network Drive
>>>>>> T: - Remote/Network Drive
>>>>>> U: - Remote/Network Drive
>>>>>> W: - Remote/Network Drive
>>>>>> X: - Remote/Network Drive
>>>>>> Y: - Remote/Network Drive
>>>>>> Z: - Remote/Network Drive
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>
 
"Herb Martin" <n...@learnquick.com> wrote...
>The following works on 2003 and Vista but is really slow (at least
>on 2003) when it encounters a disconnected network drive letter that *IS*
>mapped:
>
>ALL ONE LINE FOLLOWING:
>
>for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
>exist %%a:\lpt1 @fsutil fsinfo drivetype %%a:

....

The following seems to work under XP. Also all one command line.

(for %d in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ^
@fsutil fsinfo drivetype %d:) | find "No such " /v

This produces the following results, not including the lines of
dashes.

------
B: - Remote/Network Drive
C: - Fixed Drive
D: - Fixed Drive
F: - Remote/Network Drive
G: - CD-ROM Drive
H: - Remote/Network Drive
I: - Remote/Network Drive
J: - Remote/Network Drive
K: - Remote/Network Drive
L: - Remote/Network Drive
M: - Remote/Network Drive
P: - Remote/Network Drive
S: - Remote/Network Drive
T: - Remote/Network Drive
U: - Remote/Network Drive
V: - Remote/Network Drive
W: - Remote/Network Drive
X: - Remote/Network Drive
------

Maybe not elegant, but there are times brute force is expedient.
 
"Harlan Grove" <hrlngrv@gmail.com> wrote in message
news:0224e300-0337-4973-bb9e-aeac07c09e29@p39g2000prm.googlegroups.com...
> "Herb Martin" <n...@learnquick.com> wrote...
>>The following works on 2003 and Vista but is really slow (at least
>>on 2003) when it encounters a disconnected network drive letter that *IS*
>>mapped:
>>
>>ALL ONE LINE FOLLOWING:
>>
>>for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
>>exist %%a:\lpt1 @fsutil fsinfo drivetype %%a:

> ...
>
> The following seems to work under XP. Also all one command line.
>
> (for %d in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ^
> @fsutil fsinfo drivetype %d:) | find "No such " /v


My experience is that it is much slower to check invalid
drive letters than to just check those that (FSUtil says) exist,
but that doesn't seem to be the case with this command you
offer.

It works on (at least) XP, 2003, and Vista so I think yours is
the best I have seen so far, and I am sorry I didn't try going
right at all the drives to start with. <GRIN>

I guess it turns out that the "Fsutil fsinfo drives" is just a waste of
time and effort (programmer and computer).


Thanks


> This produces the following results, not including the lines of
> dashes.
>
> ------
> B: - Remote/Network Drive
> C: - Fixed Drive
> D: - Fixed Drive
> F: - Remote/Network Drive
> G: - CD-ROM Drive
> H: - Remote/Network Drive
> I: - Remote/Network Drive
> J: - Remote/Network Drive
> K: - Remote/Network Drive
> L: - Remote/Network Drive
> M: - Remote/Network Drive
> P: - Remote/Network Drive
> S: - Remote/Network Drive
> T: - Remote/Network Drive
> U: - Remote/Network Drive
> V: - Remote/Network Drive
> W: - Remote/Network Drive
> X: - Remote/Network Drive
> ------
>
> Maybe not elegant, but there are times brute force is expedient.
 
Herb Martin wrote:
> "Dean Wells (MVP)" <dwells@maskmsetechnology.com> wrote in message
> news:eQRnffoxIHA.1768@TK2MSFTNGP03.phx.gbl...
>> Nod, I thought of the same thing re: the letter-depth but figured it's so
>> nigh-on moot for the same reasons ...

>
> That's why I did like the pipe to find "\".
>
> Here's the current one that doesn't mess up with "Drives:"
> on XP (I hadn't notice the error until Esra pointed that
> out (I was testing under 2003 mostly and who would have
> thought that XP and 2003 which both WORK basicly
> would be different in a new way?)
>
> [Following is all one line for a batch file]
>
> @for /f %%a in ('fsutil fsinfo drives ^| find "\"') do @if not
> "%%a"=="Drives:" fsutil fsinfo drivetype %%a
>
>
> I didn't use "For" option SKIP=1 because it would be different
> for XP vs. 2003.
>


Sure that skips the text "Drives:" but it doesn't pick up my floppy
drive letter

C:\WINDOWS>qdrvc
C:\ - Fixed Drive
D:\ - Fixed Drive
E:\ - Fixed Drive
Q:\ - CD-ROM Drive

C:\WINDOWS>fsutil fsinfo drives

Drives: A:\ C:\ D:\ E:\ Q:\

C:\WINDOWS>
 
Dean Wells (MVP) wrote:
> Sadly, that still doesn't work under Vista ... the one-liner I posted
> earlier seems to work across the board ... or perhaps I missed
> something? -->
>
> fsutil fsinfo drives >"%TEMP%\%~n0.$$$" && for /f %%d in ('cmd /u /c
> type "%TEMP%\%~n0.$$$" ^| more +11 ^| findstr "[A-Z]"') do fsutil fsinfo
> drivetype %%d: & del "%TEMP%\%~n0.$$$" 2>nul
>

Yup that works here (XP Pro). I guess we were hoping for a
shorter/tidier solution.
 
Harlan Grove wrote:
> "Herb Martin" <n...@learnquick.com> wrote...
>> The following works on 2003 and Vista but is really slow (at least
>> on 2003) when it encounters a disconnected network drive letter that *IS*
>> mapped:
>>
>> ALL ONE LINE FOLLOWING:
>>
>> for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
>> exist %%a:\lpt1 @fsutil fsinfo drivetype %%a:

> ...
>
> The following seems to work under XP. Also all one command line.
>
> (for %d in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ^
> @fsutil fsinfo drivetype %d:) | find "No such " /v
>
> This produces the following results, not including the lines of
> dashes.
>
> ------
> B: - Remote/Network Drive
> C: - Fixed Drive
> D: - Fixed Drive
> F: - Remote/Network Drive
> G: - CD-ROM Drive
> H: - Remote/Network Drive
> I: - Remote/Network Drive
> J: - Remote/Network Drive
> K: - Remote/Network Drive
> L: - Remote/Network Drive
> M: - Remote/Network Drive
> P: - Remote/Network Drive
> S: - Remote/Network Drive
> T: - Remote/Network Drive
> U: - Remote/Network Drive
> V: - Remote/Network Drive
> W: - Remote/Network Drive
> X: - Remote/Network Drive
> ------
>
> Maybe not elegant, but there are times brute force is expedient.

Yes, Ok here.

C:\WINDOWS>(for %d in (A B C D E F G H I J K L M N O P Q R S T U V W X Y
Z) do @
fsutil fsinfo drivetype %d: ) | find "No such " /v
A: - Removable Drive
C: - Fixed Drive
D: - Fixed Drive
E: - Fixed Drive
Q: - CD-ROM Drive

C:\WINDOWS>
 
Back
Top