Archive: Encapsulated IfFileExists


Encapsulated IfFileExists
  Hi,

Is it possible to encapsulate multiple IfFileExists?

I`m trying to search for multiple files on the user`s hdd, and if one of them isn`t there, to search a messagebox.

Another example is, searching for multiple files (that are in multiple directories and to search for some registry keys. If one of these (Files or Registry Keys) isn`t there, to show the messagebox.

I tried to make something like this:


IfFileExists "C:\Test.txt" aha test

aha:
MessageBox MB_OK "Test.txt exists"
test:
IfFileExists "C:\Test2.txt" works not
works:
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
not:
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"


But it seems that this isn`t working.

I tried with registry too but after it check that the file exists it jumps the registry checking.

Any suggestions?

You forgot to jump out of each block.

IfFileExists"C:\Test.txt" aha test


aha:
MessageBox MB_OK "Test.txt exists"
goto end
test:
IfFileExists "C:\Test2.txt" works not
works:
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
goto end
not:
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"
>end:
I'd advise you to include logiclib.nsh and do this:
${If} ${FileExists} "C:\Test.txt"

MessageBox MB_OK "Test.txt exists"
>${Else}
${If} ${FileExists} "C:\Test2.txt"
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
${Else}
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"
${EndIf}
${EndIf}

Thanks for the info.

What if Test.txt exists and Test2.txt doesn`t?

In your example, if he find Test.txt it stops searching for Test2.txt.

How can i do so that it will check both files and if one of them isn`t there it`ll pop a message box?

I must do it for several files so the start is from two :P.


You're looking for ${IfNot} and ${AndIfNot}. See nsis.sourceforge.net/LogicLib or your NSIS\Examples\LogicLib.nsi for examples on what LogicLib can do.


Ok.

Thanks for helping me.