FileExist fail in System32 folder (ahk_32 on x64 OS) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
stealzy
Posts: 91
Joined: 01 Nov 2015, 13:43

FileExist fail in System32 folder (ahk_32 on x64 OS)

29 Jun 2018, 11:07

On windows 7x64 autohotkey32 can not see this file:

Code: Select all

f := FileOpen("C:\Windows\System32\dwm.exe","r","CP0")
	if !IsObject(f)
		MsgBox 0
MsgBox % FileExist("C:\Windows\System32\dwm.exe")
autohotkey64 works fine.
Are there any reasons for this behavior?
Last edited by stealzy on 25 Jul 2018, 12:19, edited 1 time in total.
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: FileExist fail (ahk_32 on x64 OS)

29 Jun 2018, 12:04

lexikos wrote:If you're running 32-bit AutoHotkey (or any 32-bit program) on a 64-bit OS, C:\Windows\System32 is redirected to C:\Windows\SysWow64. In that case, [file] most likely really doesn't exist at that path, as accessed from a 32-bit program.

For AutoHotkey 32-bit, use SysNative instead of System32.
Source: https://autohotkey.com/boards/viewtopic ... 679#p20679

Code: Select all

f := FileOpen("C:\Windows\SysNative\dwm.exe","r","CP0")
	if !IsObject(f)
		MsgBox 0
MsgBox % FileExist("C:\Windows\SysNative\dwm.exe")

Code: Select all

MsgBox % FileExist("C:\Windows\" (A_PtrSize = 8 ? "System32" : "SysNative") "\dwm.exe")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: -Elaphe-, downstairs, Frogrammer, Google [Bot] and 299 guests