Discussion:
Searching drives
(too old to reply)
Youri Ligotmi
2015-10-29 18:14:49 UTC
Permalink
Hi there

I need to write a script to copy files on different memory sticks,
that's quite simple (at least I know how to do it).
The problem is that according to the content of the file I have to copy
it on a particular memory stick, but the letter assigned to each memory
stick depends on the order they are plugged on the computer.
So I need a script that would scan all the local drives, read the name
and the assigned letter of each one so that I could know that MS1 is
assigned to the lette E: and MS2 to F: (and the opposite another day).
Thanks in advance

YL
Youri Ligotmi
2015-10-29 18:53:25 UTC
Permalink
Post by Youri Ligotmi
Hi there
I need to write a script to copy files on different memory sticks,
that's quite simple (at least I know how to do it).
The problem is that according to the content of the file I have to copy
it on a particular memory stick, but the letter assigned to each memory
stick depends on the order they are plugged on the computer.
So I need a script that would scan all the local drives, read the name
and the assigned letter of each one so that I could know that MS1 is
assigned to the lette E: and MS2 to F: (and the opposite another day).
Thanks in advance
YL
Found!
Google is really my friend :
http://stackoverflow.com/questions/26132913/vbscript-that-scans-for-a-certain-name-of-a-drive-instead-of-drive-letters-and
R.Wieser
2015-10-29 19:17:42 UTC
Permalink
Youri,

If you want to do it the classic way (non winmgmts) you could take a look at
:

oDrive=oFS.GetDrive("C:")
if oDrive.IsReady then
if oDrive.DriveType=2 then 'Removable
wscript.echo oDrive.VolumeName
and
wscript.echo oDrive.SerialNumber

Mind you, the above is not a script (but not far from it either), just some
pointers.

Regards,
Rudy Wieser


-- Origional message
Post by Youri Ligotmi
Post by Youri Ligotmi
Hi there
I need to write a script to copy files on different memory sticks,
that's quite simple (at least I know how to do it).
The problem is that according to the content of the file I have to copy
it on a particular memory stick, but the letter assigned to each memory
stick depends on the order they are plugged on the computer.
So I need a script that would scan all the local drives, read the name
and the assigned letter of each one so that I could know that MS1 is
assigned to the lette E: and MS2 to F: (and the opposite another day).
Thanks in advance
YL
Found!
http://stackoverflow.com/questions/26132913/vbscript-that-scans-for-a-certai
n-name-of-a-drive-instead-of-drive-letters-and
Dave "Crash" Dummy
2015-10-29 19:25:54 UTC
Permalink
Post by Youri Ligotmi
Hi there
I need to write a script to copy files on different memory sticks,
that's quite simple (at least I know how to do it). The problem is
that according to the content of the file I have to copy it on a
particular memory stick, but the letter assigned to each memory stick
depends on the order they are plugged on the computer. So I need a
script that would scan all the local drives, read the name and the
assigned letter of each one so that I could know that MS1 is assigned
to the lette E: and MS2 to F: (and the opposite another day). Thanks
in advance
Here is a simple script I wrote to retrieve the drive letters for MS1
and MS2, using information included in the Windows Scripting Host
reference supplied with Windows.

dim MS1,MS2

call GetStickDrives
msgbox "MS1 = " & MS1 & vbCRLF & "MS2 = " & MS2

Sub GetStickDrives
Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
if d.DriveType=1 then
if d.VolumeName="MS1" then MS1=d.DriveLetter
if d.VolumeName="MS2" then MS2=d.DriveLetter
end if
Next
End Sub
--
Crash

Committed to the search for intraterrestrial intelligence.
Loading...