This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Ivan.Pozdeev, Vano, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2016-01-29.03:56:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454039803.73.0.690975977832.issue26189@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-01-29 03:56:43eryksunsetrecipients: + eryksun, paul.moore, tim.golden, Vano, zach.ware, steve.dower, Ivan.Pozdeev
2016-01-29 03:56:43eryksunsetmessageid: <1454039803.73.0.690975977832.issue26189@psf.upfronthosting.co.za>
2016-01-29 03:56:43eryksunlinkissue26189 messages
2016-01-29 03:56:43eryksuncreate