Jump to content
Sign in to follow this  

FileExists() returns false in error when x86-compiled script runs on x64 Win 7

Recommended Posts

I have a 32-bit-compiled autoit script that is returning false in error when run on 64-bit Windows 7 for this code:


$Dir=@WindowsDir & "\System32\Drivers\mrxsmb10.sys"

If FileExists($Dir) Then

Msgbox(64,"File found","File '" & $Dir & "' Version " & FileGetVersion($Dir))


Msgbox(16,"Error","File '" & $Dir & "' not found.")



The file is physically in the above location (C:\Windows\System32\Drivers\Mrxsmb10.sys). When the script is compiled x86 (AutoIt 3360), it returns false (incorrect). If the same script is recompiled as x64(AutoIt 3360), it returns true (correct).

The interesting thing here is that on a 64-bit Win7 machine, this file is NOT within C:\Windows\SysWOW64\..., it is sitting at the absolute path "C:\Windows\System32\Drivers\Mrxsmb10.sys".

Thus the "If Fileexists($Dir)" from above is looking for this file at path "C:\Windows\System32\Drivers\Mrxsmb10.sys", (I validated this through debugging that variable substitution was correct). Visually verified as being present at the above path on 64-bit Windows 7.. yet 32-bit compiled script returns false (file does not exist, even when it does), but the same script, recompiled 64-bit, returns true (file exists), correct.

Unless I'm missing something obvious, I suspected this as an AutoIt bug, but am told to discuss here first. Looking for any suggestions..

Share this post

Link to post
Share on other sites

When running in X64 mode the c:\windows\System32 directory is used and when in x86 mode any reference to c:\windows\system32 will use C:\Windows\SysWOW64. This is standard Vista/Win7 behaviour.

Try running this script in SciTE with both a Y and a N on the first line and look at the files returned. (need the full SciTE4AutoIt3 version for that)

$Dir = @WindowsDir & "\System32\Drivers\*.sys"
$search = FileFindFirstFile($Dir)
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...