The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run programs from 64-bit system folder (disable redirection)
#1
One day you'll find that QM run() function does not find some programs that are in system folder (c:\windows\system32 or $system$). It happens on 64-bit Windows. It is because of file system redirection, when the program exists in the 64-bit folder (System32) but not in the 32-bit folder (SysWOW64). There are several ways to run 64-bit system programs.

1. QM 2.3.4.4. In most cases run() detects when the 32-bit system program does not exist, and then runs the 64-bit program. To launch 64-bit program explicitly, use flag 0x4000. Note that other file functions also may be redirected; only run() can disable redirection itself.
2. Use special virtual folder Sysnative instead of System32. For example, run "$windows$\Sysnative\SnippingTool.exe". However this method has some limitations, eg cannot run administrative programs, such as regedit or msconfig.
3. Use the attached class. It can be used with any file functions. Note that with run() also need flag 0x30000.
4. Use a symbolic link. See next post.

Macro __Wow64DisableWow64FsRedirection help
Code:
Copy      Help
;On Windows 64-bit, there are 2 versions of system folder: system32 and SysWOW64.
;system32 contain 64-bit files. It is used by 64-bit applications.
;SysWOW64 contain 32-bit versions of these files. It is used by 32-bit applications, including QM.
;If a function in QM or other 32-bit application tries to access a file in system32 folder, Windows redirects it to the SysWOW64 folder. Normally 32-bit applications in function calls use system32, not SysWOW64; then the same code works on all Windows version.
;This behavior is the same with QM file functions (run, str.searchpath, etc) and Windows API functions.
;The 32-bit folder contains 32-bit versions of many of the system files. However not all.
;Use this class to temporarily disable this redirection, eg when you want to run a 64-bit system file.
;Call DisableRedirection when need redirection. Call Revert as soon as possible when already don't need disabling, because other functions may fail when redirection disabled.
;The class reverts automatically when the variable dies if Revert not called.
;Disables only in current thread.
;With run() use flag 0x30000, or may not work.
;The class does nothing on 32-bit Windows. Not error.
;Note: not all system folder subfolders/files are redirected. Some redirected differently.
;More info: google for "File System Redirector" or Wow64DisableWow64FsRedirection.

;You probably noticed that on Windows 64-bit also there are 2 program files folders. The "Program Files" folder contains 64-bit apps; the "Program Files (x86)" folder contains 32-bit apps.
;The redirection is not applied to program file folders. Don't need this class.
;In QM, special folder "$program files$" expands to the 32-bit folder ("Program Files (x86)"). QM is installed there. Environment variable "%ProgramW6432%" expands to the 64-bit folder ("Program Files").

;EXAMPLE

#compile "____Wow64DisableWow64FsRedirection"
__Wow64DisableWow64FsRedirection x.DisableRedirection
run "c:\windows\system32\abcdefgh.exe" "" "" "" 0x30000
x.Revert


Attached Files
.qml   __Wow64DisableWow64FsRedirection.qml (Size: 2.93 KB / Downloads: 1,103)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)