如何在启动时在 python 中自动运行脚本 (MacOS/Windows)

问题描述

我知道你可以使用任务调度器来运行程序,但是有没有什么方法可以让程序一安装就自动运行?

我很生气地开始进入网络安全领域,我想做一个“意识计划”。脚本如下:

from tkinter import *
  
root = Tk()

w = 420
h = 120

ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()

x = (ws/2) - (w/2)
y = (hs/2) - (h*2)

root.geometry('%dx%d+%d+%d' % (w,h,x,y))

# ----------------
  
l = Label(root,text = """Oi!
Be careful""")
l.config(font =("Comic sans MS",16))

T = Text(root,height = 2,width = 42)
yeet = """This file was autorun on your PC.
It is not harmfull,just be wary of what you put on your PC !"""
T.config(font =("Comic sans MS",13))

l.pack()
T.pack()


T.insert(END,yeet)
  
mainloop()

理想情况下,我希望程序在插入带有脚本的 USB 记忆棒后立即运行。但如果文件存在于计算机上,则在启动时运行它也很好

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)