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

Get help with using AutoHotkey and its commands and hotkeys
Posts: 82
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
Posts: 1390
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: ... 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")
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
Posts: 1173
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina

Re: FileExist fail (ahk_32 on x64 OS)  Topic is solved

29 Jun 2018, 12:28

Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina
(If any of my code written for v2 has stopped working, send me a private message. I appreciate that you correct my English.)

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Axxi, blue83, just me, Smile_ and 152 guests