|
Answer» I have a script that I've written where I have hard coded an output to a PCMCIA card on a non-networked machine.
Now we are getting new MACHINES that have two PCMCIA slots and an SDHC reader, and there is talk about moving to SDHC instead of PCMCIA for the data outputs (HORAAY!).
This PRESENTS a problem to me though as the old machines only have a single PCMCIA slot so it's pretty easy to rely on the hard code. But with the new machines, a user could install the PCMCIA card in either of the two slots, or insert an SDHC card. I'd like to read the state of the three slots automagically and write to the device based on which one is available.
ETA: If there are multiple devices available, I would currently prefer the failsafe to write to any/all of the available devices, with no user input as to which to select.
The important part: I do not want to rely on user input for this if at all possible.Code: [Select]@ECHO off set driveletter= 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 U Z) do ( if exist "%%D:\" ( echo.>%%D:\testifwritable.txt && ( del %%D:\testifwritable.txt set driveletter=%%D goto jumpout ) ) ) :jumpout
REM if no writable drive found... if "%driveletter%"=="" goto end
REM your code here
:end
The above should find the first writable drive letter of a series. It will be in the variable %driveletter%. If the variable is BLANK, no letter corresponding to a writable volume was found.
In place of the whole alphabet, PUT the drive letter(s) you want to test e.g.
Code: [Select]for %%D in (L M N) do ( note spaces
|