Programs run with AHK have unusual environment (Win 64-bit)
I use Autohotkey to launch, well, everything. But i noticed some unusual differences when I run things with Autohotkey, and when I run things with explorer.
For example, I have cmd.exe assigned as a hotkey.
When I run cmd.exe from autohotkey, i cannot find certain files (i.e. defrag.exe).
when I run cmd.exe from start->run->cmd.exe, I can find the files.
This appears to be windows somehow hiding the files from processes launched from Autohotkey. Any idea what this could be?
I'm running on a Windows XP 64-bit build with SP2
PATH variables are the same.
What's different is the following...
AHK launched CMD environment:
CommonProgramFiles=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
ProgramFiles=C:\Program Files (x86)
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramW6432= does not exist
PROCESSOR_ARCHITEW6432= does not exist
ProgramW6432= does not exist
__COMPAT_LAYER= does not exist
My guess is that the ProgramFiles environments are causing something wrong, why there is a difference in env variables I have NO idea.
Thanks again for any insight.
Source: MSDN: Running 32-bit Applications
WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows.
This is important for application compatibility because System32 contains 64-bit files, while SysWOW64 contains 32-bit files. Since cmd.exe is in System32, "Run cmd.exe" actually runs a 32-bit version of cmd.exe which is located in SysWOW64. Try the following instead:
Source: MSDN: File System Redirector
Whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to a new directory, %windir%\SysWOW64.
DllCall("Wow64DisableWow64FsRedirection", "uint*", OldValue) Run cmd.exe DllCall("Wow64RevertWow64FsRedirection", "uint", OldValue)
Lexikos, your solution worked!
I'm not sure I fully understand it tho. I'll read up on the links you provided.
How odd that System32 contains 64bit files, while SysWOW64 contains 32bit ones...you'd think it would be the other way around.
Anyway, I did quickly run a test of running SysWOW64\cmd.exe vs system32\cmd, and it confirmed the difference I was seeing in the command environments (everything except the __COMPAT_LAYER=LUA entry).
I guess windows 64 is doing some additional work behind the scenes. It also seems to hide access to certain files in the system32...interesting
Thanks again everyone for the valuable assistance. I hope someone else finds this helpful.