我想做一个脚本,将检查其他脚本是否正在运行,如果他们关闭,然后它会运行它们
问题是,其他复制的脚本与与脚本本身位于同一文件夹中的文件交互。当您启动checker时,它会从自己的目录运行脚本,结果发现脚本无法访问它们的文件。如何在脚本所在的文件夹中模拟单击并运行脚本
现在我有了这个密码。脚本立即打开和关闭(因为它们找不到文件)
import psutil
import os
import time
def cheak(name):
for proc in psutil.process_iter():
if (proc.name() == name):
return True
return False
while 1:
if not cheak('FoodBotWithPhoto.exe'):
os.system(r"start C:\Users\Professional\Desktop\BotRecepti\FoodBotWithPhoto.exe")
if not cheak('VideoBot.exe'):
os.system(r"start C:\Users\Professional\Desktop\BOT\VideoBot.exe")
if not cheak('main_v2.0.exe'):
os.system(r"start C:\Users\Professional\Desktop\Botgamebomb\main_v2.0.exe")
if not cheak('VK.exe'):
os.system(r"start C:\Users\Professional\Desktop\BotFiveFactov\VK.exe")
time.sleep(10)
目前没有回答
相关问题 更多 >
编程相关推荐