Hi all, I'm having some challenges using pywin32 to launch a 32-bit Windows application, but the tricky thing is that I cannot reproduce the problem on my machine or my coworkers (person B) machine, but only on some other persons' (person C) machine, so my changes to debug this are very rare & limited.
The code that is not able to launch the exe is on Person C's computer ("testscript.py"): from pathlib import Path import win32process path_to_exe = Path(r"C:\path to some\folder\some.exe") (h_process, _, dw_process_id, _) = win32process.CreateProcess( None, # module name str(path_to_exe), # command line None, # Process handle not inheritable. None, # Thread handle not inheritable. 0, # Set handle inheritance to FALSE. 0, # Creation flags. None, # Use parent's environment block. str(Path(path_to_exe).parent), # If None - use parent's starting directory. win32process.STARTUPINFO(), ) # STARTUPINFO structure. You can see that there is only a simple call to win32process.CreateProcess. Here are the *combinations which do work*: 1) My machine & some.exe with win32process.CreateProcess 2) Person B & some.exe with win32process.CreateProcess 3) Person C & C:\Windows\system32\notepad.exe with win32process.CreateProcess 4) Person C & C:\Windows\SysWOW64\notepad.exe with win32process.CreateProcess 5) Person C & some.exe, launching directly by double-clicking So, for some reason Person C can launch some.exe without win32process.CreateProcess, and can launch 32-bit and 64-bit versions of notepad.exe with win32process.CreateProcess, *but launching some.exe with win32process.CreateProcess throws the error. *The some.exe is an old 32-bit app, which is not publicly available anywhere and of which source code I don't have. I've had time to debug with Person C to try to run the testscript.py with different versions of pywin32 (few latest), with a fresh install of Python 3.8.6 32-bit and also on a portable (WinPython) 3.7.x 32-bit, and it kept giving the same "%1 is not a valid Win32 application" error. PROCESS MONITOR logs ===================== I have also used the Process Monitor from Sysinternals to make a short recording with my machine on Person C's machine while running testscript.py. Here are the .dll/.pyd files (disregarding __init__ files) that were in the logs with at least once with "Result == SUCCESS". 1) The following DLLs on *both* machines with same path (mine & Person C) - "python.exe" PGHook.dll C:\Program Files (x86)\Avecto\Privilege Guard Client\PGHook.dll KernelBase.dll C:\Windows\SysWOW64\KernelBase.dll SHCore.dll C:\Windows\SysWOW64\SHCore.dll advapi32.dll C:\Windows\SysWOW64\advapi32.dll bcrypt.dll C:\Windows\SysWOW64\bcrypt.dll bcryptprimitives.dll C:\Windows\SysWOW64\bcryptprimitives.dll cfgmgr32.dll C:\Windows\SysWOW64\cfgmgr32.dll combase.dll C:\Windows\SysWOW64\combase.dll cryptbase.dll C:\Windows\SysWOW64\cryptbase.dll cryptsp.dll C:\Windows\SysWOW64\cryptsp.dll gdi32.dll C:\Windows\SysWOW64\gdi32.dll gdi32full.dll C:\Windows\SysWOW64\gdi32full.dll imm32.dll C:\Windows\SysWOW64\imm32.dll kernel.appcore.dll C:\Windows\SysWOW64\kernel.appcore.dll kernel32.dll C:\Windows\SysWOW64\kernel32.dll msvcp_win.dll C:\Windows\SysWOW64\msvcp_win.dll msvcrt.dll C:\Windows\SysWOW64\msvcrt.dll ntdll.dll C:\Windows\SysWOW64\ntdll.dll ole32.dll C:\Windows\SysWOW64\ole32.dll oleaut32.dll C:\Windows\SysWOW64\oleaut32.dll powrprof.dll C:\Windows\SysWOW64\powrprof.dll profapi.dll C:\Windows\SysWOW64\profapi.dll psapi.dll C:\Windows\SysWOW64\psapi.dll rpcrt4.dll C:\Windows\SysWOW64\rpcrt4.dll rsaenh.dll C:\Windows\SysWOW64\rsaenh.dll sechost.dll C:\Windows\SysWOW64\sechost.dll shell32.dll C:\Windows\SysWOW64\shell32.dll shlwapi.dll C:\Windows\SysWOW64\shlwapi.dll sspicli.dll C:\Windows\SysWOW64\sspicli.dll tzres.dll C:\Windows\SysWOW64\tzres.dll ucrtbase.dll C:\Windows\SysWOW64\ucrtbase.dll umpdc.dll C:\Windows\SysWOW64\umpdc.dll user32.dll C:\Windows\SysWOW64\user32.dll version.dll C:\Windows\SysWOW64\version.dll win32u.dll C:\Windows\SysWOW64\win32u.dll windows.storage.dll C:\Windows\SysWOW64\windows.storage.dll ws2_32.dll C:\Windows\SysWOW64\ws2_32.dll ntdll.dll C:\Windows\System32\ntdll.dll wow64.dll C:\Windows\System32\wow64.dll wow64cpu.dll C:\Windows\System32\wow64cpu.dll wow64win.dll C:\Windows\System32\wow64win.dll 2) The following DLLs with *different paths* (mine & Person C) - "python.exe" On my machine pywintypes37.dll C:\Windows\SysWOW64\pywintypes37.dll win32process.pyd C:\tmp\testfix\python\Lib\site-packages\win32\win32process.pyd python3.dll C:\tmp\testfix\python\python3.dll python37.dll C:\tmp\testfix\python\python37.dll vcruntime140.dll C:\tmp\testfix\python\vcruntime140.dll On Person C's machine pywintypes38.dll C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pywin32_system32\pywintypes38.dll win32process.pyd C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\win32\win32process.pyd python3.dll C:\Users\user\AppData\Local\Programs\Python\Python38-32\python3.dll python38.dll C:\Users\user\AppData\Local\Programs\Python\Python38-32\python38.dll vcruntime140.dll C:\Users\user\AppData\Local\Programs\Python\Python38-32\vcruntime140.dll Seems that the DLLs listed here are essentially the same (also tested with the same Python 3.7 and actually the same dll's and wheels, too.) 3) The DLL's with that are loaded with "some.exe" (my PC only): PGHook.dll C:\Program Files (x86)\Avecto\Privilege Guard Client\PGHook.dll mfc42.dll C:\Users\me\OneDrive - Mycompany\Desktop\some\mfc42.dll CoreMessaging.dll C:\Windows\SysWOW64\CoreMessaging.dll CoreUIComponents.dll C:\Windows\SysWOW64\CoreUIComponents.dll KernelBase.dll C:\Windows\SysWOW64\KernelBase.dll SHCore.dll C:\Windows\SysWOW64\SHCore.dll TextInputFramework.dll C:\Windows\SysWOW64\TextInputFramework.dll WinTypes.dll C:\Windows\SysWOW64\WinTypes.dll advapi32.dll C:\Windows\SysWOW64\advapi32.dll bcrypt.dll C:\Windows\SysWOW64\bcrypt.dll bcryptprimitives.dll C:\Windows\SysWOW64\bcryptprimitives.dll cfgmgr32.dll C:\Windows\SysWOW64\cfgmgr32.dll combase.dll C:\Windows\SysWOW64\combase.dll cryptbase.dll C:\Windows\SysWOW64\cryptbase.dll cryptsp.dll C:\Windows\SysWOW64\cryptsp.dll gdi32.dll C:\Windows\SysWOW64\gdi32.dll gdi32full.dll C:\Windows\SysWOW64\gdi32full.dll iertutil.dll C:\Windows\SysWOW64\iertutil.dll imm32.dll C:\Windows\SysWOW64\imm32.dll kernel.appcore.dll C:\Windows\SysWOW64\kernel.appcore.dll kernel32.dll C:\Windows\SysWOW64\kernel32.dll msctf.dll C:\Windows\SysWOW64\msctf.dll msvcp_win.dll C:\Windows\SysWOW64\msvcp_win.dll msvcrt.dll C:\Windows\SysWOW64\msvcrt.dll ntmarta.dll C:\Windows\SysWOW64\ntmarta.dll ole32.dll C:\Windows\SysWOW64\ole32.dll oleaut32.dll C:\Windows\SysWOW64\oleaut32.dll powrprof.dll C:\Windows\SysWOW64\powrprof.dll profapi.dll C:\Windows\SysWOW64\profapi.dll rpcrt4.dll C:\Windows\SysWOW64\rpcrt4.dll rsaenh.dll C:\Windows\SysWOW64\rsaenh.dll sechost.dll C:\Windows\SysWOW64\sechost.dll shell32.dll C:\Windows\SysWOW64\shell32.dll shlwapi.dll C:\Windows\SysWOW64\shlwapi.dll sspicli.dll C:\Windows\SysWOW64\sspicli.dll tzres.dll C:\Windows\SysWOW64\tzres.dll ucrtbase.dll C:\Windows\SysWOW64\ucrtbase.dll umpdc.dll C:\Windows\SysWOW64\umpdc.dll user32.dll C:\Windows\SysWOW64\user32.dll uxtheme.dll C:\Windows\SysWOW64\uxtheme.dll win32u.dll C:\Windows\SysWOW64\win32u.dll windows.storage.dll C:\Windows\SysWOW64\windows.storage.dll wow64.dll C:\Windows\System32\wow64.dll wow64cpu.dll C:\Windows\System32\wow64cpu.dll wow64win.dll C:\Windows\System32\wow64win.dll comctl32.dll C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.18362.1198_none_bb60abf7ec91ff24\comctl32.dll These were alse accessed by some.exe but not found (on my machine): MFC42LOC.DLL C:\Windows\SysWOW64\MFC42LOC.DLL rpcss.dll C:\Windows\SysWOW64\rpcss.dll wow64log.dll C:\Windows\System32\wow64log.dll On person C's machine, I the Process Monitor did not have any logs from "some.exe", probably because it was not successfully launched *Question:* Is this somehow known behaviour or related to some bug in pywin32? How could I debug to find out what is the problem? As said, the debugging is difficult and must be done in well organized manner, since there are no problems on my computer, and I have to make appointments for testing anything. Regards, Niko Pasanen
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32