代码如下:

subp = subprocess.Popen(cwd_path + "test.exe", cwd = cwd_path, shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)

执行时,从异常捕获中看到错误 WindowsError: [Error 6] The handle is invalid

最后在 https://bugs.python.org/issue3905 找到了解决方法

Specifying PIPE for all subprocess.Popen handles is the only way I've
found to get around this problem:

p = subprocess.Popen(["python", "-c", "print 32"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

p.stdin.close()

subp = subprocess.Popen(cwd_path + "test.exe", cwd = cwd_path, shell = True, stdin=subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
subp.stdin.close()

使用python的subprocess启动windows程序提示WindowsError: [Error 6] The handle is invalid的更多相关文章

  1. 解决PEnetwork启动的时候提示"An error occured while starting the "TCP/IP Registry Compatibility" Service (2)!"程序将立即退出的问题

    解决PEnetwork启动的时候提示"An error occured while starting the "TCP/IP Registry Compatibility" ...

  2. 启动Windows防火墙提示“0x8007042c"

    win8.1 启动防火墙是报错:启动Windows防火墙提示“0x8007042c" 一.检查服务 1,右击开始->运行->输入“services.msc” 打开服务 在框中找到 ...

  3. 工作自动化,替代手工操作,使用python操作MFC、windows程序

    目录 背景--为什么要自动化操作? 方法--怎么实现自动化操作? 查找窗体 发送消息 获取文本 总结 背景--为什么要自动化操作? 工作中总是遇到反复重复性的工作?怎么用程序把它变成自动化操作?将程序 ...

  4. 通过weburl 启动windows程序

    1. 注册表修改 建立一个reg文件 执行导入  以RunLocal协议为例子 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\RunL ...

  5. windows下启动某程序提示缺失**.dll文件的处理方法

    一.背景: 1.os : windows7 64bit 旗舰版 2.启动ftp服务端软件时提示缺失mfc100.dll文件 以上情形亲测有效 二.修复 2.1 从https://cn.dll-file ...

  6. 如何在python脚本下启动django程序

    直接上图

  7. 启动eclipse时候提示错误Error:Could not create the Java Virtual Machine. Error:A Fatal exception has occurred,Program will exit.

    我的是neon3版本 解决办法是: 首先把这两个选项勾选,才能看到eclipse.ini完整的文件名.然后用记事本等工具打开编辑. 新版的里面原本是这样: -startup plugins/org.e ...

  8. subprocess.Popen运行报错WindowsError: [Error 740]

    subprocess.Popen在win10下运行报740错时 使用os.popen替换,运行OK,exe程序成功启动 import subprocess import uiautomation as ...

  9. SpringBoot启动项目时提示:Error:(3, 32) java: 程序包org.springframework.boot不存在

    场景 在IDEA中新建SpringBoot项目,后启动项目时提示: Error:(3, 32) java: 程序包org.springframework.boot不存在 实现 将pom.xml中par ...

随机推荐

  1. MFC ListContrl 的使用

    m_ISESTList.SetExtendedStyle(m_ISESTList.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINE ...

  2. AsyncTask 轻量级的异步类

    初步:http://www.cnblogs.com/devinzhang/archive/2012/02/13/2350070.html 详细:http://blog.csdn.net/liuhe68 ...

  3. VC_MFC水波纹控件,开源

    代码和效果图: https://github.com/wjx0912/MfcWaterEffect 集成以下5个文件即可: watereffect\DIB.hwatereffect\DIB.cppwa ...

  4. Knockoutjs实例 - 属性绑定(Bindings)之流程控制(Control flow)

    一.foreach binding 使用此功能可以方便我们循环遍历输出某个数组.集合中的内容. (1).循环遍历输出数组 View Row Code 1 <script type="t ...

  5. sqlserver 跨服务器访问数据

    需求:两个一模一样的表,分别分布在两个服务器的数据库上,现在要在一个表中,查看这两个表的内容,并让Id排序 1:在本地数据库查询分析器中,运行以下两段语句: --创建链接服务器 exec sp_add ...

  6. POJO类中的任何布尔类型的变量,都不要加is

    POJO类中的任何布尔类型的变量,都不要加is,否则部分框架解析会引起序列化错误. 定义为基本数据类型boolean isSuccess:的属性,它的方法也是isSuccess(),HSF框架在反向解 ...

  7. JavaScript常用函数和方法

    alert('Hello World!') //方法用于显示带有一条指定消息和一个 OK 按钮的警告框. //定义js函数 function Foo(name) { console.log(name) ...

  8. 53. Maximum Subarray

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  9. 【学】CSS3基础实例1 - 用CSS3做网页中的小三角,以及transition的用法

    自开了博客园已经有2周了吧,虽然转载了一些觉得比较有用的文章之外还没有开始写自己的一些学习记录,那就从今天开始. 目前看了妙味的不少视频,有css+html,js的基础和中级也都看完了,作业也都做了, ...

  10. 在共享DLL中使用MFC

    使用VS2008,在项目属性中有一项MFC的使用,有三种设置: 1.使用标准Windows库 2.在共享DLL中使用MFC 3.在静态库中使用MFC          第一种顾名思义.        ...