Perl on Windows, file associations and I/O redirection

前端 未结 2 1359
故里飘歌
故里飘歌 2020-12-17 02:58

Can someone explain the difference between calling a perl script via file association versus calling the same script explicitly via perl.exe?

Apparentl

相关标签:
2条回答
  • 2020-12-17 03:24

    It looks like it was a known bug in Windows 2000: STDIN/STDOUT Redirection May Not Work If Started from a File Association.

    I get the same behaviour you describe with Strawberry Perl on WinXP, however once I created the registry entry described in the above article (even though the reg entry is targetted at Win2K), stdin works as expected.

    For completeness, in case the link above goes away, the reg entry it suggests creating is:

    1. Start Registry Editor.
    2. Locate and then click the following key in the registry: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
    3. On the Edit menu, click Add Value, and then add the following registry value:
      • Value name: InheritConsoleHandles
      • Data type: REG_DWORD
      • Radix: Decimal
      • Value data: 1
    4. Quit Registry Editor.

    Edit: I ought to add that even though the KB article claims it was fixed in XP SP1, I've got XP SP3 installed. So whether MS have broken this, or never fixed it completely, I can't say!

    0 讨论(0)
  • 2020-12-17 03:30

    I know this is an old thread, but it's important to note that Microsoft appears to have reversed the polarity of this setting in Windows 10. No idea why they would do that, but this had me pulling my hair out for a day. See my other posted question (Perl Scripts on Windows 10 run from Explorer but not Command Prompt), and especially the linked MSDN post there.

    0 讨论(0)
提交回复
热议问题