1

I want to use Inno Setup to install a tool into Visual Studio.

My tool should be installed to an existing folder, with an existing file in the folder.

I know how to search this file. I use this code in Inno Setup:

function InitializeSetup: Boolean;
begin
  // Alle Unterverzeichnisse durchsuchen
  DirDepth := -1;
  // suche nach der Datei im Programme-Ordner beginnen
  SearchPath := ExpandConstant('{pf}');
  // suche nach folgender Datei
  SearchFile := 'main tool.exe';
  SearchForFile;
  // wenn Datei nicht gefunden Fehlermeldung und Setup beenden
  if not FileFound then
    MsgBox('Installierte Version konnte nicht ermittelt werden.', mbCriticalError, mb_OK)
  else
    Result := true;
end;

My problem is, the file "main tool.exe" could be in more than one folder. It could be in a folder like "aaa" or "bbb v1". My program must be installed in the folder "bbb v1", but the first name of this folder is always "bbb" and the "v1" could be different...

So, how can I search this folder in Inno Setup?

mghie
  • 32,028
  • 6
  • 87
  • 129
  • So, you're looking for a way to find all folders partially matching a certain name pattern, let's say `bbb*` and in every such found folder you want to check whether there's a specific file. Did I get that right ? – TLama May 04 '14 at 20:44
  • Yet one more thing, will you know the parent folder for that searched directory, or you expect to perform a recursive search of all subfolders of a parent directory ? Interesting question anyway! – TLama May 05 '14 at 10:02
  • I don´t know... I know there are allways one folder which is called "bbb v1". But "v1" could be always different like "v21" or "v123". In this folder is always one file, its always "main tool.exe". The file could also be in another folder... But my Setup must be installed in the folder "bbb ..." – vbnet_newer May 05 '14 at 11:00
  • So, that `bbb` folder can be anywhere ? In any subfolder level of a certain directory ? That's quite critical, because you shouldn't search for your folder e.g. on the whole drive. That would take ages on certain systems... It should be no problem to write a function which will recursively search for a folder in a certain directory, but your users can just wait for a long time... Anyway, are you definitely sure there is no other way to find that folder ? – TLama May 05 '14 at 11:07
  • ahh ok. i know what you mean. the folder could be in "c:\program files\" or in "c:\programme\" – vbnet_newer May 05 '14 at 11:30
  • You should try to identify a Registry location that indicates where the application is installed. Almost every program will have at least one fixed Registry entry that can point you at the correct place, removing the need to search at all. If this fails, simply ask the user to locate it themselves (and verify that they selected the correct location). Searching folders is **never** the correct solution. – Miral May 06 '14 at 21:07
  • how can i identify a registry location and use them in inno-setup? – vbnet_newer May 28 '14 at 21:27

0 Answers0