本站分享:AI、大数据、数据分析师培训认证考试,包括:Python培训Excel培训Matlab培训SPSS培训SAS培训R语言培训Hadoop培训Amos培训Stata培训Eviews培训

一键开机启动添加(python)_开机启动python脚本

python培训 cdadata 3391℃

一键开机启动添加(python)

关键词:python开机启动   开机启动python脚本   linux开机启动 python

添加文件到run注册表里面去

## file2autorun.py
import sys
import win32api
import win32con
import os
def addfile2autorun(path):
runpath = “SoftwareMicrosoftWindowsCurrentVersionRun”
hKey = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, runpath, 0, win32con.KEY_SET_VALUE)
path = os.path.abspath(path)
if False == os.path.isfile(path):
return False
(filepath, filename) = os.path.split(path)
win32api.RegSetValueEx(hKey, filename, 0, win32con.REG_SZ, path)
win32api.RegCloseKey(hKey)
return True
if len(sys.argv) == 1:
print “usage: file2autorun.py %filepath%”
else:
path = sys.argv[1];
if addfile2autorun(path):
print “added %s to autorun” % (path,)
else:
print “fail add %s to autorun!!!” % (path, )

右键菜单添加懒得写了,人肉改注册表:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTPython.FileshellAdd2AutoRun]

[HKEY_CLASSES_ROOTPython.FileshellAdd2AutoRuncommand]
@=”python “e:\python\file2autorun.py” “%1″”

转载请注明:数据分析 » 一键开机启动添加(python)_开机启动python脚本

喜欢 (0)or分享 (0)