Code: Select all
msgbox % A_ComSpec ; C:\Windows\System32\cmd.exe
Run %A_ComSpec% /k ; Will open C:\Windows\SysWOW64\cmd.exe
What should I do if I want to run a 64-bit cmd?
Thank you.
Code: Select all
msgbox % A_ComSpec ; C:\Windows\System32\cmd.exe
Run %A_ComSpec% /k ; Will open C:\Windows\SysWOW64\cmd.exe
Btw, I can't reproduce your result above in the Run case. What are you exactly running?https://www.howtogeek.com/326509/whats-the-difference-between-the-system32-and-syswow64-folders-in-windows/ wrote:On 64-bit versions of Windows, you have two separate Program Files folders. But it doesn’t end there. You also have two separate system directories where DLL libraries and executables are stored: System32 and SysWOW64. Despite the names, System32 is full of 64-bit files and SysWOW64 is full of 32-bit files.
Code: Select all
;note: on 64-bit PCs:
;C:\Windows\System32 contains 64-bit files (yes, *64*-bit/system*32*)
;C:\Windows\SysWOW64 contains 32-bit files (yes, *32*-bit/wow*64*)
;note: 'WoW64' stands for: Windows 32-bit on Windows 64-bit
;test file redirection
;note: this script assumes that you run 32-bit AHK on a 64-bit PC
;vPath := "C:\Windows\System32\notepad.exe"
vPath := A_ComSpec ;C:\Windows\System32\cmd.exe
DllCall("kernel32\Wow64DisableWow64FsRedirection", "Ptr*",0)
FileGetSize, vSize64, % vPath
DllCall("kernel32\Wow64RevertWow64FsRedirection", "Ptr*",0)
FileGetSize, vSize32, % vPath
MsgBox, % "32-bit: " vSize32 "`r`n" "64-bit: " vSize64
return
Code: Select all
;test file redirection (requires 64-bit PC, 32-bit AHK)
if !A_Is64bitOS
{
MsgBox, % "error: you must test the script on a 64-bit PC"
return
}
if (A_PtrSize = 8)
{
MsgBox, % "error: you must test the script with 32-bit AHK"
return
}
vPath := "C:\Windows\System32\notepad.exe"
vPath := A_ComSpec ;C:\Windows\System32\cmd.exe
Run, % vPath,,, vPID
WinWait, % "ahk_pid " vPID
WinGet, vPPath, ProcessPath, % "ahk_pid " vPID
MsgBox, % vPath "`r`n" vPPath
return
This is the easiest way.What should I do if I want to run a 64-bit cmd?
Code: Select all
try Run %A_WinDir%\SysNative\cmd.exe
catch
Run %A_ComSpec%
Users browsing this forum: Starker and 260 guests