PC Review


Reply
Thread Tools Rate Thread

Batch file to show Network drives

 
 
joshboski
Guest
Posts: n/a
 
      3rd Jun 2008
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.
 
Reply With Quote
 
 
 
 
Bob I
Guest
Posts: n/a
 
      3rd Jun 2008
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/microsof...mdprompt.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.


 
Reply With Quote
 
joshboski
Guest
Posts: n/a
 
      3rd Jun 2008
On Jun 3, 9:21 am, Bob I <bire...@yahoo.com> wrote:
> 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/microsof...mdprompt.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.


My apologies, that I did not include this also...I need the list of
local hard drives as well
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008

"joshboski" <(E-Mail Removed)> wrote in message
news:4e9ec7fc-5000-4ab5-bbe8-(E-Mail Removed)...
> On Jun 3, 9:21 am, Bob I <bire...@yahoo.com> wrote:
>> 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/microsof...mdprompt.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.

>
> My apologies, that I did not include this also...I need the list of
> local hard drives as well


As Bob recommended: net use (for networked drives), and
mountvol | find ":\" for local drives.


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008

"joshboski" <(E-Mail Removed)> wrote in message
news:4e9ec7fc-5000-4ab5-bbe8-(E-Mail Removed)...
> On Jun 3, 9:21 am, Bob I <bire...@yahoo.com> wrote:
>> 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/microsof...mdprompt.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.

>
> My apologies, that I did not include this also...I need the list of
> local hard drives as well


If you want something a little snazzier then you can use this script
file and massage it to give you the information you want. You need
to invoke it like so in your batch file: cscript //nologo c:\diskparms.vbs

Const Removable = 1
Const Fixed = 2
Const Network = 3
Const CDROM = 4
Const RAMDisk = 5

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set drives = oFSO.Drives

NewLine=Chr(10)
Line = ""

For Each drive In drives
Line = Line & "Drive " & drive.Path
Line = Line & " " & ShowDriveType(Drive)
If drive.IsReady Then Line = Line & ", ready" Else Line = Line & ", not
ready"

If drive.IsReady Then
If drive.DriveType=Network Then
Line = Line & ", Label=" & drive.ShareName
Else
Line = Line & ", Label=" & drive.VolumeName
End If

Line = Line & ", FS=" & drive.FileSystem
Line = Line & ", Total=" & Int(drive.TotalSize/1000000)
Line = Line & ", Free=" & Int(drive.FreeSpace/1000000)
Line = Line & ", Available=" & Int(drive.AvailableSpace/1000000)
Line = Line & ", Serial=" & Hex(drive.SerialNumber)
End If

Line = Line & NewLine
Next
wscript.echo Line

Function ShowDriveType(Drive)
Select Case drive.DriveType
Case Removable
T = "Removable"
Case Fixed
T = "Fixed"
Case Network
T = "Network"
Case CDROM
T = "CD-ROM"
Case RAMDisk
T = "RAM Disk"
Case Else
T = "Unknown"
End Select
ShowDriveType = T
End Function


 
Reply With Quote
 
Dean Wells \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008
Not as backwards compatible as some solutions offered here but,
nonetheless, worth a mention -

C:\>fsutil fsinfo drives

Drives: C:\ D:\ E:\ Z:\

.... iterating through that list and using -

C:\>fsutil fsinfo drivetype <insert drive letter here>

.... will return greater detail regarding the type of drive assignment.

--
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


"Bob I" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/microsof...mdprompt.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.

>



 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008

"Dean Wells (MVP)" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Not as backwards compatible as some solutions offered here but,
> nonetheless, worth a mention -
>
> C:\>fsutil fsinfo drives
>
> Drives: C:\ D:\ E:\ Z:\
>
> ... iterating through that list and using -
>
> C:\>fsutil fsinfo drivetype <insert drive letter here>
>
> ... will return greater detail regarding the type of drive assignment.
>
> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology


For reasons which I am unable to explain, Microsoft turned the
output of the command "fsutil fsinfo drives" into a set of $00-delimited
strings. The result is that I am unable to extract the individual
drive letters out of the string "Drives: C:\ D:\ E:\ F:\ Q:\ R:\",
using a batch file. Do you know of a way to do this?


 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
      3rd Jun 2008
joshboski <(E-Mail Removed)> wrote:
> My apologies, that I did not include this also...I need the list of
> local hard drives as well


53} How can I quietly test if a disk device is ready or not?
http://www.netikka.net/tsneti/info/tscmd053.htm

54} How can I get the type of a disk device?
http://www.netikka.net/tsneti/info/tscmd054.htm

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
private.php?do=newpm&u= <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
 
Reply With Quote
 
Dean Wells \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008
Nod, I encountered the same limitation ... irritating isn't it.

Take a look at the 'bootSwitch.cmd' script here -

ftp://falcon.msetechnology.com/scrip...Switch.cmd.txt

.... it contains a means of resolving this behavior by exploiting an
all-too-often useful unicode oddity. Other ways were and probably still
are available though; didn't give it much thought after I came it that
one.

As I'm sure you know, part of the enjoyment of solving these kind of
annoyances is the creativity involved in making such a limited
environment play nicely ... this is one of my favs. to date.

--
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


"Pegasus (MVP)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Dean Wells (MVP)" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Not as backwards compatible as some solutions offered here but,
>> nonetheless, worth a mention -
>>
>> C:\>fsutil fsinfo drives
>>
>> Drives: C:\ D:\ E:\ Z:\
>>
>> ... iterating through that list and using -
>>
>> C:\>fsutil fsinfo drivetype <insert drive letter here>
>>
>> ... will return greater detail regarding the type of drive
>> assignment.
>>
>> --
>> Dean Wells [MVP / Directory Services]
>> MSEtechnology

>
> For reasons which I am unable to explain, Microsoft turned the
> output of the command "fsutil fsinfo drives" into a set of
> $00-delimited
> strings. The result is that I am unable to extract the individual
> drive letters out of the string "Drives: C:\ D:\ E:\ F:\ Q:\ R:\",
> using a batch file. Do you know of a way to do this?
>
>



 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      3rd Jun 2008

"Dean Wells (MVP)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Nod, I encountered the same limitation ... irritating isn't it.
>
> Take a look at the 'bootSwitch.cmd' script here -
>
> ftp://falcon.msetechnology.com/scrip...Switch.cmd.txt
>
> ... it contains a means of resolving this behavior by exploiting an
> all-too-often useful unicode oddity. Other ways were and probably still
> are available though; didn't give it much thought after I came it that
> one.
>
> As I'm sure you know, part of the enjoyment of solving these kind of
> annoyances is the creativity involved in making such a limited environment
> play nicely ... this is one of my favs. to date.
>
> --
> Dean Wells [MVP / Directory Services]


Nicely done and highly imaginative but not my favourite.
I'm a great user of batch files but I wonder how long it
took you to get these lines just right and how maintainable
they are . . .
fsutil fsinfo drives >"%TEMP%\%~n0.$$$"
for /f "tokens=1 delims=\ skip=10" %%d in
('cmd /u /c type "%TEMP%\%~n0.$$$" ^| find /v ""') do echo %%d


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Batch file to show Network drives Bob I Microsoft Windows 2000 CMD Promt 48 5th Jun 2008 08:16 PM
batch file to show newtork drives joshboski Windows XP Help 2 3rd Jun 2008 02:51 PM
Firefox File->Open does not show mapped network drives bvandew Windows Vista General Discussion 1 14th Nov 2007 11:52 PM
Batch file to map or disconnect drives on a network John Doue Windows XP General 2 4th Dec 2004 05:04 PM
vbs or batch script to show disk drives and available space jamil hussain Microsoft Access 0 19th Aug 2003 10:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:19 PM.