Python学习(五):启动和关闭exe

#启动
import win32api
#0.打开ONENOTE
win32api.ShellExecute(0,'open',r'C:\...\ONENOTEM.EXE','','',1)
#1.打开TIM
win32api.ShellExecute(0,'open',r'C:\...\TIM.exe','','',1)
#2.打开微信
win32api.ShellExecute(0,'open',r'C:\...\WeChat.exe','','',1)
#3.打开chrome
win32api.ShellExecute(0,'open',r'C:\...\chrome.exe','','',1)
#4.打开IDEA
win32api.ShellExecute(0,'open',r'C:\...\idea64.exe','','',1)
#5.打开PyCharm
win32api.ShellExecute(0,'open',r'C:\...\pycharm64.exe','','',1)

#关闭
import os
os.system('chcp 65001')
#0.关闭ONENOTE
os.system("taskkill /F /IM ONENOTEM.EXE")
#1.关闭TIM
os.system("taskkill /F /IM TIM.exe")
#2.关闭微信
os.system("taskkill /F /IM WeChat.exe")
#3.关闭chrome
os.system("taskkill /F /IM chrome.exe")
#4.关闭IDEA
os.system("taskkill /F /IM idea64.exe")
#5.关闭PyCharm
os.system("taskkill /F /IM pycharm64.exe")

 

posted @ 2020-02-04 22:29  liw66  阅读(1122)  评论(0编辑  收藏  举报