• Notice regarding image hosts and attachments. See here.

DOS FIND Query

Soldato
Joined
23 Nov 2004
Posts
3,794
Hi,

I'm struggeling to get find to work in one of my scripts.

I have error checking and i want different outcomes if it doesn't find "HP LaserJet 4 Plus Driver" to if it does.

If i search for "12233rfHP LaserJet 4 Plus Driver" it still finds the string, even with the /I flag not set. (I have another script calling the below script which outputs to Results.txt)

Is there another way of doing this? (See script below).

Code:
Echo Searching for HP LaserJet 4 Plus Driver String...
find "HP LaserJet 4 Plus" Results.txt
	if not %errorlevel% == 0 goto FAIL
	echo %1 SUCCESS! HP LaserJet 4 Plus Driver is being used! >>Success.txt
	goto FINISH
:FAIL
	Echo %1 Is Not Using the HP LaserJet 4 Plus Driver" >>Failures.txt
:FINISH
exit
 
I think you made a typo...

remove the quote after (Driver")
seems to work now

:)

------------------------
Echo Searching for HP LaserJet 4 Plus Driver String...
find "HP LaserJet 4 Plus" Results.txt
if not %errorlevel% == 0 goto FAIL
echo %1 SUCCESS! HP LaserJet 4 Plus Driver is being used! >> Success.txt
goto FINISH

:FAIL
Echo %1 Is Not Using the HP LaserJet 4 Plus Driver >> Failures.txt

:FINISH
exit

---------------------
 
bitslice said:
I think you made a typo...

remove the quote after (Driver")
seems to work now

:)

------------------------
Echo Searching for HP LaserJet 4 Plus Driver String...
find "HP LaserJet 4 Plus" Results.txt
if not %errorlevel% == 0 goto FAIL
echo %1 SUCCESS! HP LaserJet 4 Plus Driver is being used! >> Success.txt
goto FINISH

:FAIL
Echo %1 Is Not Using the HP LaserJet 4 Plus Driver >> Failures.txt

:FINISH
exit

---------------------

Ah yea i did spot that, earlier, and changed that but it still finds the key.

It just found "123ewdfHP LaserJet 4 Plus"

Any other ideas?
 
:confused:

ummm, are we talking about the same thing ?

with the modded batch file:

if text in 'results.txt' = "HP LaserJet 4 Plus" then success.txt is written
if text in 'results.txt' = "1234-HP LaserJet 4 Plus" then success.txt is written
if text in 'results.txt' = "HP LaserJet 4 Plus-1234" then success.txt is written

if text in 'results.txt' = "HP LaserXXXJet 4 Plus" then failure.txt is written
if text in 'results.txt' = "wibbleywoo" then failure.txt is written


...which is what you want isn't it ? :confused:


....are you changing the search string to test the code or something ?
because it'll find the string in "123ewdfHP LaserJet 4 Plus"
but not in "HP Laser123ewdf Jet 4 Plus"


:)


.
 
Last edited:
Back
Top Bottom