代码如下:

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. mysql workbench is well-designed

    我用过mysql纯cli(command line),即纯命令行的执行环境,也用过navicat for mysql pro 破解版,甚至还用过比较高端的sqlyog,最后我还是选择了官方的workb ...

  2. libtcc使用问题一二

    问题来由: powersniff(参考博客的文章,在qq群下载最新版本)目前使用lua作为分析插件,但熟练lua的人不多.所以,移植python和tcc两类语言作为插件. tcc(即tiny c),h ...

  3. mysql-创建库之问题

    一.在登入mysql命令行,创建数据库时报错 ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'xiaolu ...

  4. mac android studio 编译时报Class JavaLaunchHelper is implemented in both

    Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Cont ...

  5. phpnow修改默认站点根目录的方法

    本文转载自:http://blog.csdn.net/andy_eeipla/article/details/7832082 对于phpnow,经测试,修改Apache-20\conf\extra\h ...

  6. 关闭和开启oracle

    1.使用sqlplus 启动和关闭数据库. 答:使用sqlplus以sysdba的身份登录数据库 因为我的数据库是启动状态,所以我就先演示数据库的关闭 数据库的关闭使用语句shutdown immed ...

  7. [Linux] Linux下谁在消耗我们的cache

    一.缘由: 曾经看到MySQL服务器上Cache占用特别大,其实大家都知道这是合理的,这些都是可用内存: 那么问题来了,是谁在占用这些Cache呢?如果去掉不合理的Cache占用,系统内存会更充分的得 ...

  8. SQL语句 DML,DDL,DCL

    数据控制语言(DCL)是用来设置或者更改数据库用户或角色权限的语句,这些语句包括GRANT.DENY.REVOKE等语句,在默认状态下,只有 sysadmin.dbcreator.db_owner或d ...

  9. CRM JS 设置lookup字段 setSimpleLookupValue

    function setSimpleLookupValue(LookupId, Type, Id, Name) { /// <summary> /// Sets the value for ...

  10. Mono addin 学习笔记 2

    下面分析用xml描述文件的方式来进行插件定义 定义扩展点如下: public interface ISnippetProvider { string GetText (string shortcut) ...