I need to do this from an MS-DOS 7.10 boot floppy. I'm thinking something like: SET Found=FALSE FOR %%i IN (%PATH%) DO IF EXIST %%i\MYPROG.EXE SET Found=TRUE IF '%Found%' == 'FALSE' GOTO ERRMSGnnI haven't tested this yet, but is there a better more direct way?
Under MS DOS 7.1 I can't suggest a better way, just code
SET Found=FALSE FOR %%i IN (%PATH%) DO IF EXIST %%i.\MYPROG.EXE SET Found=TRUE IF "%Found%"=="FALSE" ...
where %%i. takes care of paths like C:\ while working fine with no backslash suffixed ones too and avoid spaces around == in IF statement (use double quotes to embrace members).
That's what I expected. Thanks for the tip about using the dot. Do you have an example of how the single quote or spaces could cause a problem? I've seen it both ways, and in more confusing ways too. I remember reading long ago that one was superior to the other but can't remember where or why.
Double quotes are THE RULE for IF statement and should always be coded even if their occurrence seems not requested. The ' may lead to error if the variable/string after expanded contains a quote (rare but not impossible, e.g. Joe's_Report.doc). To avoid spaces before and after == (or = in SET) is THE RULE too since again spaces may cause mismatch when strings have leading or trailing blanks.
| « [Solved] Use a batch file to renam... | [Solved] Read txt files through ba... » |