FAFOpen sees files FileExist can't see?

Started by IJRobson, October 16, 2013, 06:17:58 AM

Previous topic - Next topic

IJRobson

I have been using a script to find files on a drive and to obtain Version details of the executable files.

This works fine on Windows XP but when I run the same script on Windows 7 I find that some files returned by FAFOpen are reported by FileExist() as "file not found" (Return code 0)?

I have System and Hidden switched on the FAFOpen so I guess this an access rights issue with Windows 7 (hiding System files)?

Any Ideas how I can get FileExist to see these files?

Thanks

Deana

Maybe try adding IntControl 5 to the script. IntControl 5 controls whether system & hidden files or directories are seen and processed.

Deana F.
Technical Support
Wilson WindowWare Inc.

td

Out of curiosity, are you calling the FAF extender and FileExist from the same instance of a WinBatch process or are you collecting files in one  WinBatch process and later checking for their existence in another WinBatch process? Also, are the problematic files on a network share or mapped drive? 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

IJRobson

Deana,

I will try INTControl 5 to see what difference it makes.  However, why should the default value be different between Windows XP and Windows 7?

TD,

The FAF and FileExist are in the same Process even in the same While loop reading the FAF returned file names, which is why it was confusing me, as the file was there two WinBatch commands earlier.

Thanks

IJRobson

The Problem Files are all on the local HDD (not network drives) and generally relate to Microsoft  Programs and Windows O/S files.

Deana

Quote from: IJRobson on October 17, 2013, 10:26:54 AM
Deana,

I will try INTControl 5 to see what difference it makes.  However, why should the default value be different between Windows XP and Windows 7?


No it wouldn't be different. What is the root directory you are working with on Windows 7? Post a simple example that reproduces the problem on your system.
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

I tested the following code on Win 7 with IntControl 5 and without. The results are the same. Do you have problem with this code?

Code (winbatch) Select
AddExtender("WWFAF44I.DLL",0,"WWFAF64I.DLL")

IntControl(5,1,0,0,0)

; Initialize flags for readability
fsHidden = 1   ; Include hidden files
fsSystem = 2   ; Include system files
fsRecurse = 16  ; Look in sub directories
fsIgnoreReparse = 128 ; ignore reparse points
DatFile = DirScript():'FAFFindInt5.txt'
File = FileOpen(DatFile, "WRITE")

; Open a search handle
fsHandle = fafOpen("C:\Program Files (x86)\", "*.EXE", fsHidden|fsSystem|fsRecurse|fsIgnoreReparse)
LastFilePath = ""

; Perform the search
While @TRUE
  sFound = fafFind(fsHandle)
  If sFound == "" Then Break
  If FileExist(SFound) Then
    FileWrite(File, SFound)
  EndIf       
EndWhile
FafClose(fsHandle)

FileClose(File)
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Quote from: IJRobson on October 17, 2013, 10:30:43 AM
The Problem Files are all on the local HDD (not network drives) and generally relate to Microsoft  Programs and Windows O/S files.

FileExist and the FAF extender use different OS functionality to accomplish their respective tasks.  For the most part, the FAF extender uses NTFS file meta data to collect file name and paths.  The FileExist function actually touches the file to determine if it is minimally accessible.   It is certainly conceivable that one or more Windows 7 OS files could be locked down such that they would be unaccessible to even an elevated administrative user. 

Also, IIRC, IntControl 5 does not effect the behavior of the FileExist function.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

I but together a quick script to test all the files  under the Windows directory on a 64-bit Windows 7 system using the the FAF extender and the FileExist function.  If I ran the script using 64-bit WinBatch, it found exactly one file that  FileExist reported as non-existent even though the the FAF extender found it and it was visible in a shell Explorer window. Only the system had any permissions for that file so it makes perfect sense that FileExist would not report the file as existing.

On the other hand, if I ran the same script using 32-bit WinBatch, FileExist reported 2649 files as non-existent.  This is because the extender default is to turn off file redirection on 64-bit systems but FileExist is still effected by file redirections.  So most of the 2649 file reported as not found existed under the system32 directory but not under the sysWOW64 directory that FileExist would use instead of system32.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Deana

Interesting. Tony. So should this code resolve the issue. It disable file redirection for the FileExist call.

Code (winbatch) Select
AddExtender("WWFAF44I.DLL",0,"WWFAF64I.DLL")

; Initialize flags for readability
fsHidden = 1   ; Include hidden files
fsSystem = 2   ; Include system files
fsRecurse = 16  ; Look in sub directories
fsIgnoreReparse = 128 ; Used to hande repars point on Win7 user directories

DatFile = DirScript():'FAFFind.txt'
File = FileOpen(DatFile, "WRITE")

; Open a search handle
fsHandle = fafOpen("C:\windows\", "*.*", fsHidden|fsSystem|fsRecurse|fsIgnoreReparse)
LastFilePath = ""

; Perform the search
While @TRUE
  sFound = fafFind(fsHandle)
  If sFound == "" Then Break
  oldvalue = IntControl( 92, "disable", 0, 0, 0 )
  ret = FileExist( "C:\Windows\System32\cmd.exe" )
  IntControl( 92, "revert", oldvalue, 0, 0 )
  If ret Then
    FileWrite(File, SFound)
  EndIf       
EndWhile
FafClose(fsHandle)

FileClose(File)
Deana F.
Technical Support
Wilson WindowWare Inc.

IJRobson

Interesting, the compiled WinBatch EXE is 32 bit and the machines I have seen this problem on are running 64 bit Windows 7.  Whilst I was investigating this I did notice that one of the Files FAF found but FileExist did not was only present in the System32 no 64 Bit version was available.  So that appears to match.

I will try your tweak tomorrow and see what affect it has.

Thanks