1.

Solve : need help with compound if?

Answer»

I need help wwith this compound if statement in a Dos Batch file. I am checking to see if two files exist on the drive. if ?.txt exist and blackd.exe. If both exist I would like to end the batch file. if one or neither exist continue processing through the batch file. I have alll of it working except the part list below. the secomnd if statment never CHANGES in by test it is alway "false2" I think it is because of the long file name in the directory path, becasue event when I place a test file in the directroy if is still show "false2". I anyone unstand this I really need your help. I been trying to get this to work for 4 day now.

@echo off
set agenttoken ="false1"
set blackd="false2"
set exepath=%2

if exist "c:\Token\%1.txt" set agenttoken="true"
if exist "c:\program files\agent\desktop agent\blackd.exe" set blackd="true"

echo %agenttoken%
echo %blackd%

if %agenttoken% == %blackd% goto ENDauggie!
To make SURE that the blackd file really exist the way it's typed in you can run:

dir "c:\program files\agent\desktop agent\blackd.exe"

If the OUTPUT says "The system cannot find the path specified." or "File Not Found" then you have a hint.

Besides this, I see that your echo %agenttoken% probably never shows "false1" because of the additional space before the assignment operator in set agenttoken ="false1"

In fact the following:

Code: [Select]set agenttoken ="false1"
set agenttoken="false111"
echo %agenttoken %
echo %agenttoken%will show:
"false1"
"false111"


Hope this helps The logic looks OK, although I think it can be done simpler. Here are a couple of things to try:

Try taking out the space in your "set agenttoken"
Code: [Select]set agenttoken="false1"When comparing strings, surround them both with something to help avoid ERRORS if one ends up blank
Code: [Select]if {%agenttoken%}=={%blackd%} goto END



Discussion

No Comment Found