import subprocess """ demonstrates a bug with stdin. If a doskey macro is set from a script specified by HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun then any stdin piped to a program executed by python will not be read. The bug is either in python subprocess module or in Windows and can be reproduced with commandline python.exe testsubproc.py < mytxtfile.txt The C++ code for stdintest.exe is: --------------------------------------------------- #include void main(int argc, char* argv[]) { char mstr[2001]; mstr[0] = 0; std::cout << "enter something on stdin\n"; std::cin >> mstr; std::cout << "\nGot input from stdin:\n" << mstr; } ---------------------------------------------------- The registry key could be: ---------------------------------------------------- HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\mymacros.cmd ---------------------------------------------------- and mymacros.cmd could be: ---------------------------------------------------- @doskey setVC64="C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat" amd64 $T @doskey setVC32="C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86 $T ---------------------------------------------------- mytxtfile.txt is any one-line text file """ def main(): return subprocess.call(args=['stdintest.exe'], shell=True) if __name__ == '__main__': main()