Python论坛 - 国内最好的Python中文社区

标题: Python实现隐藏自启 [打印本页]

作者: 13308778992    时间: 2017-1-27 12:07
标题: Python实现隐藏自启
不多bb直接上代码:
  1. import inspect,os
  2. import shutil
  3. import win32con, win32api
  4. def path():
  5.    caller_file=inspect.stack()[1][1]
  6.    return os.path.abspath(os.path.dirname(caller_file))
  7. def copy():
  8.    shutil.copyfile(path()+'autorun.py', 'C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\key.py')
  9.    win32api.SetFileAttributes('C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\key.py', win32con.FILE_ATTRIBUTE_HIDDEN)
  10. copy()
复制代码
key.py和autorun.py换成你想自启的文件的文件名





欢迎光临 Python论坛 - 国内最好的Python中文社区 (https://bbs.pythontab.com/) Powered by Discuz! X3.4