In my script I am checking whether a directory and two files in this directory exist. While the first returns the correct value, the second check does not. I've checked it multiple times that these files exist in the designated directory but Inno Setup will always tell me that they do not exist. This is happening on a virtual Windows Server, and can't be reproduced on my local machine. There it always returns the correct Value.
UpdatePath := ExpandConstant('{app}');
if DirExists(UpdatePath) then begin
ExePath := UpdatePath+'\Application.exe';
ConfigFilePath := UpdatePath+'\Application.exe.config';
if FileExists(ExePath) and FileExists(ConfigFilePath) then begin //this one returns incorrect values
//Do Stuff
end else begin
MsgBox(FmtMessage(CustomMessage('DirPageFileNotFound'), [ExePath, ConfigFilePath]),mbInformation,MB_OK);
Result := False;
end;
end else begin
MsgBox(FmtMessage(CustomMessage('DirPageDirectoryNotFound'), [UpdatePath]),mbInformation,MB_OK);
Result := False;
end;
As you can see, I'm checking for an executable which can also be executed when double-clicked. It is there but Inno Setup will always tell me that it's not there. Is the virtual environment messing with it? What is happening here?
To debug the issue, try adding following code. Then check the log file of the installer and the output of the
dir
command:The
FileExists
internally usesFindFirst
/FindNext
andGetFileAttributes
. So this is to find out what causes the problem.My wild guess is that the target machine is 64-bit and file system redirection jumps in for some reason.
Try using
EnableFsRedirection
to disable the redirection before you callFileExists
: