none
Nasty File Association Regression Bug in Windows 10 Console RRS feed

  • Question

  • There is a nasty regression bug in the Windows 10 console.  If you execute a file that gets executed through a file association, the process' stdout and stderr are not connected, so all console output disappears.  This is critically important for those of us who use Perl and Python for our administrative tasks, but here is a test case that reproduces the problem with standard components.  I redefine the ".vbs" extension to use the console CScript instead of the GUI WScript, which means this requires an administrator shell:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\Tmp>assoc .vbs
    .vbs=VBSFile
    
    C:\Tmp>ftype vbsfile
    vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %*
    
    C:\Tmp>type x.vbs
    WScript.Echo "Hello, World!"
    
    C:\Tmp>ftype VBSFile="%SystemRoot%\System32\CScript.exe" "%1" %*
    VBSFile="C:\Windows\System32\CScript.exe" "%1" %*
    
    C:\Tmp>cscript x.vbs
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Hello, World!
    
    C:\Tmp>x.vbs
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Hello, World!
    
    C:\Tmp>

    As you see, if you invoke it through the CScript command it works, but if you run that exact sequence on Windows 10, the final command produces no output.

    This is a BIG DEAL.


    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

    Friday, July 31, 2015 4:52 AM

Answers

  • I can now answer my own question.

    This issue raised its ugly head many years ago -- like 15 years ago, during the Windows 2000/XP era.  There was a hotfix included in XP SP1 that solved the problem by adding a new registry hack, mentioned in a Knowledge Base article, KB321788.  The recommendation at that point was to go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer and create a DWORD value InheritConsoleHandles set to 1.

    It appears that the sense of this switch has now been reversed.  If I pop into the registry and set InheritConsoleHandles to 0, then Windows 10 works just like 8 and 7.  Hopefully this will help the next command line dinosaur to come along.  Now, can I vote my own response as the correct answer?


    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

    • Marked as answer by Tim Roberts Friday, July 31, 2015 10:02 PM
    Friday, July 31, 2015 10:02 PM