1、将微信小程序添加到电脑桌面,如图
2、查找小程序所在路径
4、查找微信 WechatAppLauncher.exe所在路径(鼠标放置在桌面小程序图标上右键->打开文件所在位置) 如图:
5、小程序路径即为“D:\install\communication\WeChat\WechatAppLauncher.exe -launch_appid=wxece3a9a4c82f58c9” (WechatAppLauncher.exe所在路径 -launch_appid=wx…路径)
6、使用 subprocess 启用小程序
# coding=utf-8
import sys
import subprocess
import os
from time import sleep
import win32com.client
import json
import chardet
#检查进程是否存在
def check_exsit(process_name):
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name like "%{}%"'.format(process_name))
if len(processCodeCov) > 0:
print(f"{process_name}:进程启动成功")
else:
print(f"{process_name}:进程启动失败")
def PrintEnv():
print("os: " + sys.platform)
print("python version: " + sys.version)
#关闭程序
def close_exe(name):
# os.popen("taskkill /IM " + name + " -F")
os.popen("taskkill /IM " + name)
print(f"{name}:进程已关闭")
def open_exe(xcx_path):
subprocess.Popen(xcx_path) #打开小程序
xcx_path = "D:\\install\\communication\\WeChat\\WechatAppLauncher.exe -launch_appid=wxece3a9a4c82f58c9"
open_exe(xcx_path) #启动程序