Python中调用exe同步等待的使用(ShellExecuteEx)

参考https://www.programcreek.com/python/example/97304/win32com.shell.shell.ShellExecuteEx

import win32api
import win32event
import win32process
import win32con
import os

from win32com.shell.shell import ShellExecuteEx
from win32com.shell import shellcon

PATH_380B_PRJ = r"..\..\..\xxx.atomprj"


def Callexe():
    abspath = os.getcwd()
    prjpath = os.path.join(abspath, str(PATH_380B_PRJ))

    exePath = r"C:\123.exe"
    param = str(prjpath) + r"      -guicmd    rebuild -compileroption  release -exit"

    #win32api.ShellExecute(0,"open",exePath,param,'',1)

    process_info = ShellExecuteEx(nShow=win32con.SW_HIDE,
                                  fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                                  lpVerb='runas',
                                  lpFile=exePath,
                                  lpParameters=param)

    win32event.WaitForSingleObject(process_info['hProcess'], 600000)
    ret = win32process.GetExitCodeProcess(process_info['hProcess'])
    win32api.CloseHandle(process_info['hProcess'])


    #handle = win32process.CreateProcess(exePath, param, None, None, 0, win32process.CREATE_NO_WINDOW, None, None, win32process.STARTUPINFO())
    print("end")
    win32event.WaitForSingleObject(handle[0], -1)

 

 


#encoding=utf-8
import subprocess
sh=r'F:\program files\SHplayer\5.0.2.34\SHPlayer.exe'#这里r可以可以不管空格和中文字符的烦恼
avi=r’F:test.avi’
runavi=subprocess.Popen(sh+' '+avi)
--------------------- 
作者:jirryzhang 
来源:CSDN 
原文:https://blog.csdn.net/jirryzhang/article/details/52791883 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

win32api.ShellExecute(0, "open", 'bintobin.exe', 'defaultGroup.bin', '', 1)

 

win32api.ShellExecute(0, "open", 'softbuilder_new.exe', str(hwxToolName) + '_hwx.cfg', '', 1)

 

subp = subprocess.Popen(binPath + '\\softbuilder_new.exe' + ' ' + str(hwxToolName) + '_hwx.cfg', shell=False)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值