I'm trying to write a quick batch file that scans all the drives on a system (D-Z) and when it finds the desired file it runs it.
So far, I'm able to do that just fine with the following simple script.
For %%I In (D,E,F,G,H,I,J,K,L,M,N,O,P
) Do If Exist "%%I:\MyUniqueFile.exe" "%%I:\MyUniqueFile.exe"
The problem I have is that Windows complains if a drive is unavailable. For example a floppy or CD drive with no disk inserted.
If I click continue, it works fine. So my question is, how can I add error handling so that it will not present the user with an error and simply continue to the next drive?
I'm hoping to make this non-OS dependant, simply work across most or all MS Operating Systems.