lrstndm

FileExists not working on System32

12 posts in this topic

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

Share this post


Link to post
Share on other sites



Why does that matter?

So for a 32-bit machine I need to compile a 32 bit version. And for a 64-bit machine I need to compile a 64 bit version?

What changed in the meantime? Because this always worked for me?

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Jos 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

The problem is that the same code works on a Windows Server 2008 R2 (64-bit system) both the 32-bit and 64-bit compiled code. But on a WIndows 10 (64-bit system) only the 64 bit compiled code works. I don't know how this is possible.

Share this post


Link to post
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") )

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thank you jguinch. That fixed the problem!

Do you know why this came just up today with me jguinch?

Is this because of the update from Windows 10?

Edited by lrstndm

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Thank you again:) That helped a lot.

Edited by lrstndm

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

  • Similar Content

    • dreivilo47
      By dreivilo47
      When I want to test Example 1 of Function _IECreate (AutoIt Help File), I see that function _IECreate doesn't work in Windows 10.
      Syntax Check (Ctrl+F5) gives no errors.
       
      Example 1:
      ; Create a browser window and navigate to a website #include <IE.au3> Local $oIE = _IECreate("www.autoitscript.com")  
      The error I receive with F5 (Tools, Go) in SciTE:

    • Chaym
      By Chaym
      Does AutoIT supported  in Windows 10 OS (x64)?
      After installing AutoIT in x64 OS and recompiling code,
      I get a lot of error messages...
       
    • kristo
      By kristo
      The DriveGetDrive command returned all drives (option "ALL") for years now and my program could always rely on that function. Suddenly a drive letter that was created with the subst command does not appear in the list of drives anymore. And it clearly did, because I used to react to a certain subst command by reacting to new or revoked (subst /D) drive letters.
      Why is that? I think this a bug because there's no way left to list ALL drive letters anymore.
      And why should I use an API command for that when this was already built in for years?

       
    • kokoilie
      By kokoilie
      I'm making a program that has a combo control in a gui and back in win7 when the window was focused the scroll wheel could be used to scroll through it's contents, now i'm using win10 and i have to put the mouse on that control to scroll up and down.
      Since now the scroll wheel works depending on where the mouse is, is there a way to make it no matter where on the gui the pointer is?
      Also if the only way to do it is some complex hotkey functions will it work with pressing space to toggle a checkbox?
      If you need to see what i have so far let me know and i'll copy it here.
    • ModemJunki
      By ModemJunki
      Hello,
      In Windows 10 PowerShell, one can do this to change the metric for a NIC in Windows 10:
      Get-NetAdapter | Where-Object -FilterScript {$_.InterfaceAlias -Eq "Ethernet 2"} | Set-NetIPInterface -InterfaceMetric 2 I know I can script the above PowerShell line (and it works!), but I wanted to try something I hadn't done before after looking into jguinch's most excellent Network configuration UDF. I wanted to make use of the SetIPConnectionMetric method in the WMI classes. There is an example VBscript here but this is not for Windows 10. Using AutoIT would also give better control over capturing error return codes than with PowerShell.
      But I cannot get my script to work! The return from SetIPConnectionMetric() is 0, which would indicate success. Yet the change does not happen. I also tried WMI methods using .put_ but this fails.
      Anyone more experienced than I have ideas to make this work?
      #RequireAdmin _SetNicInterfaceMetric2("Ethernet 2", "2") Func _SetNicInterfaceMetric2($NIC_NAME, $METRIC) Local $s_setIndx = 0 $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") $colNICItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = '" & $NIC_NAME & "'", "WQL") If IsObj($colNICItems) Then For $objItem In $colNICItems $s_nicIndex = $objItem.Index Next ConsoleWrite("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'" & @CRLF) $colNAC = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'", "WQL") If IsObj($colNAC) Then For $objNetCard In $colNAC If $METRIC <> $objNetCard.IPConnectionMetric Then ConsoleWrite("Metric was set to " & $objNetCard.IPConnectionMetric & ". Setting to " & $METRIC & "." & @CRLF) $s_isSet = $objNetCard.SetIPConnectionMetric($METRIC) ConsoleWrite("SetIPConnectionMetric Result = " & $s_isSet & @CRLF) Else ConsoleWrite("Metric is already set to " & $METRIC & @CRLF) EndIf Next EndIf EndIf EndFunc ;==>_SetNicInterfaceMetric2