I require a VBScript to iterate through the drives installed in my system that are capable of read and write (essentially, what WMI would classify as a LogicalDisk type 3), searching for a file in the root directory of each. Once the first instance of the file is found, the drive letter is returned in a variable.
So... let's say I have the following drives:
E: (USB Stick)
Let's then say I'm looking for a "Tag" file such as one named "Drive.tag".
Let's say the Drive.tag file exists as G:\Drive.tag.
I want the script to iterate through the drives, find the Drive.tag file in the root of G:\ and return "G" to me. Drives not available for both Read AND Write (in this case F, H, and possibly E) should not be touched.
I'm not sure how to implement this in VBScript, it's a new language to me.
A batch file to do this operation would look like this:
for /F "skip=2 tokens=2 delims=," %%p in ('wmic logicaldisk where drivetype^=3 get deviceid^,volumename /format:csv') do (
if EXIST "%%p\Drive.tag" (
@echo FindMedia: Found backup drive at Volume %%p:.
It's that behavior I'm trying to reproduce in VBScript.
Thanks in advance!