Eryk Sun added the comment:
Ensure that the .lnk target is the expected path to python.exe:
C:\Temp>py -3 -c ^
More? "from win32com import client^
More?
More? lnk = client.Dispatch('WScript.Shell').^
More? CreateShortCut('python.lnk')^
More?
More? print('target:\n%s' % lnk.Targetpath)
target:
C:\Program Files\Python27\python.exe
You can attach a debugger to cmd and set a breakpoint on CreateProcessW. The
first time it's called is for the failed attempt to execute the .lnk as a PE
image (cmd doesn't make assumptions about file extensions). The 2nd time, if
called, should be from a ShellExecute worker thread. For example (this time
using Windows 7):
C:\Temp>.\python.lnk -c "import sys;sys.exit(42)"
Breakpoint 0 hit
kernel32!CreateProcessW:
00000000`76c307a0 4883ec68 sub rsp,68h
0:000> du @rdx
00000000`003942f0 ".\python.lnk -c "import sys;sys"
00000000`00394330 ".exit(42)""
0:000> g
Breakpoint 0 hit
kernel32!CreateProcessW:
00000000`76c307a0 4883ec68 sub rsp,68h
0:001> du @rdx
00000000`003d3640 ""C:\Program Files\Python27\pytho"
00000000`003d3680 "n.exe" -c "import sys;sys.exit("
00000000`003d36c0 "42)""
0:001> k2
Child-SP RetAddr Call Site
00000000`0149e4e8 000007fe`fde3b9c3 kernel32!CreateProcessW
00000000`0149e4f0 000007fe`fde3b72b SHELL32!_SHCreateProcess+0x32b
0:001> g
C:\Temp>echo %errorlevel%
42
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26189>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com