|
Answer» I would like to find a WORD in a dos text and then make a TEST with this word. Is it possible? for exemple in a text I have "liscence: yes", I want to go and see if there is the word "yes" in the text and if it's ok I want to launch an apply.Use the find or findstr to do the search. Then check the errorlevel returned (0 = found, 1 = not found) and branch to the logic you wish to perform.
Use the /? for commands you need more information on.
Hope this helps. how COULD i use the errorlevel 0 or1 with XP? when i use it i always obtain an errorlevel 0. i don't know whyERRORLEVEL processing is always messy. Even though the compare appears as equal it's really for greater than or equal. The best way to write the code is do the ERRORLEVEL checking in reverse sequence and always branch around the remaining IF statements.
Example: Code: [SELECT] find argument filename if errorlevel 1 goto notfound if errorlevel 0 goto found
:notfound . . . goto :eof
:found . . . goto :eof
If the IF statements were reversed, the check for errorlevel 0 would always be true, no matter what the actual value is.
If you would post your code, this would be a lot easier.
Hope this helps. my code is:
findstr /R /I /M /C:"no LICENSES" D:\....\...txt if else errorlevel 1 goto licences if errorlevel 0 goto nolicences :licences echo licensesavailable>>D:\...\....txt goto end :nolicences echo nolicensesavailable>>D:\...\....txt :end
I use windows XP and i'm not sure that i can use the errorlevel command in that case is there an other cmd?You don't need another command and yes, ERRORLEVEL is available on XP. Remove the ELSE from the first IF statement.
Why was it necessary to use FINDSTR and all those switches for such a simple bit of logic?
|