python批处理,一键打开vscode窗口,分别加载jeecg前后端项目,并运行前后端服务.
import subprocess import time
# VsCode打开后端项目 cmd1 = ["code","D:\pro\JeecgBoot-v3.7.1\jeecg-boot"] process1 = subprocess.Popen(cmd1, stdout=subprocess.PIPE, shell=True) output1, _ = process1.communicate() print(output1.decode('utf-8')) # VsCode打开前端项目 cmd2 = ["code", "D:\pro\JeecgBoot-v3.7.1\jeecgboot-vue3"] process2 = subprocess.Popen(cmd2, stdout=subprocess.PIPE, shell=True) output2, _ = process2.communicate() print(output2.decode('utf-8'))
time.sleep(20)
# 打开后端服务 cmd3 = ['start', 'cmd', '/k', 'cd D:\pro\JeecgBoot-v3.7.1\jeecg-boot && java -cp D:/pro/JeecgBoot-v3.7.1/jeecg-boot/classpath.jar org.jeecg.JeecgSystemApplication'] subprocess.run(cmd3, shell=True, check=True)
time.sleep(20)
# 打开前端服务 cmd4 = ['start', 'cmd', '/k', 'cd D:\pro\JeecgBoot-v3.7.1\jeecgboot-vue3 && yarn run dev'] subprocess.run(cmd4, shell=True, check=True)
win11添加右键运行python文件
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell\Run] "Icon"="D:\\dev\\python_icon.ico" [HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell\Run\Command] @="D:\\dev\\Python396\\python.exe \"%1\" %*"