Perl on Windows, file associations and I/O redirection

前端 未结 2 1358
故里飘歌
故里飘歌 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!

提交回复
热议问题