Jump to content

FileExists not working on System32


lrstndm
 Share

Recommended Posts

Hi all,

I want to check if a file exists under the System32 folder: C:\Windows\System32\inetsrv\rewrite.dll

The following code always worked for me:

$string = @SystemDir & "\inetsrv\rewrite.dll"
ConsoleWrite(FileExists($string))

But yesterday I updated my Windows 10 with the last "big" update and now my @SystemDir returns the following string:

C:\Windows\SysWOW64

And before it was:

C:\Windows\System32

So I thought I change my code to:

$string = @WindowsDir & "\System32\inetsrv\rewrite.dll"
ConsoleWrite(FileExists($string))

But this code also does not work. I tried to run it as administrator but this also didn't work.

What am I doing wrong?

Regards,

lrstndm

Link to comment
Share on other sites

  • Developers

You are running the script with the x86 version of AutoIt3 in stead of the x64 version.

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.
  :)

Link to comment
Share on other sites

on my system windows 8.1 64 bit with the last version of autoit

run script x86  @systemDir   =  C:\Windows\SysWOW64

run script x64  @SystemDir   = C:\Windows\system32

the same if i compile the script

 

Edited by HAL9000
i was wrong
Link to comment
Share on other sites

  • Developers

Which makes sense right as that is the way Microsoft solved the coexistence of X84 and X86 programs.

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.
  :)

Link to comment
Share on other sites

Is it possible to disable (or something else) this. So that it always checks this good.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$string = @WindowsDir & "\System32\inetsrv\rewrite.dll"
ConsoleWrite(FileExists($string))

I currently changed the code with the above code. The UseX64 has to be on 'y' because else it returns 0 (file not exists).

But when I check the string variable is says the exact same value. I just cannot imagine how this could be wrong.

Is it possible someone explains this?

Link to comment
Share on other sites

  • Developers

It seems you do not understand yet how windows handles the mixed x64 and x86 processes on an x64 Windows version.
Maybe you need to do a little more reading on that. :)

Either way, a couple of questions before being able to give you the right answer:

  • Do the computers, that run this script, all have an X64 OS installed?
  • What exactly is it you want to test for: the existence of rewrite.dll in the X86 or x64 world?
  • What action should this lead to based on the found information?

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.
  :)

Link to comment
Share on other sites

Have a look at the _WinAPI_Wow64EnableWow64FsRedirection function :

#include <WinAPIFiles.au3>

MsgBox (0, "", FileExists(@WindowsDir & "\System32\inetsrv\test") )

_WinAPI_Wow64EnableWow64FsRedirection ( False )
MsgBox (0, "", FileExists(@WindowsDir & "\System32\inetsrv\test") )

 

Link to comment
Share on other sites

Link to comment
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
 Share

×
×
  • Create New...