Python论坛 - 国内最好的Python中文社区
标题:
Python实现隐藏自启
[打印本页]
作者:
13308778992
时间:
2017-1-27 12:07
标题:
Python实现隐藏自启
不多bb直接上代码:
import inspect,os
import shutil
import win32con, win32api
def path():
caller_file=inspect.stack()[1][1]
return os.path.abspath(os.path.dirname(caller_file))
def copy():
shutil.copyfile(path()+'autorun.py', 'C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\key.py')
win32api.SetFileAttributes('C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\key.py', win32con.FILE_ATTRIBUTE_HIDDEN)
copy()
复制代码
把
key.py和
autorun.py换成你想自启的文件的文件名
欢迎光临 Python论坛 - 国内最好的Python中文社区 (https://bbs.pythontab.com/)
Powered by Discuz! X3.4