On Windows the page file c:\pagefile.sys is always open and locked. In NativeAccess we try using GetFileAttributes but this will return ERROR_SHARING_VIOLATION and -1, leading Tcl to believe the file does not exist. Similar code is in NativeStat fails for the same reason. So we cannot currently test for the existence or size or mtime for this file. However if we then try FindFirstFile for the pathname we can get this information even though the file is in use.
The attached patch tries FindFirstFile when GetFIleAttributes fails. GFA is a bit faster on my system than FFF so I prefer to only try this when necessary. I've not checked for the GetLastError() code as well as I don't know if other error codes might still be appropriate for continuing to check using FFF.
patch file
I have applied this patch with a new test to the HEAD 8.6 code.
Had to back out this patch, because of bug [3608360]: Incompatible behaviour of "file exists".
I would prefer another solution for this problem. If GetFileAttributes() returns
ERROR_SHARING_VIOLATION, then we know that the file exists but
is not readable and not writable. Let's thread that as a special case.
Fixed now on all branches.