Python Windows中将Python添加到注册表中
来源:互联网 发布:淘宝sony耳机真假 编辑:程序博客网 时间:2024/06/06 03:14
import sysfrom winreg import *# tweak as necessaryversion = sys.version[:3]installpath = sys.prefixregpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)installkey = "InstallPath"pythonkey = "PythonPath"pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( installpath, installpath, installpath)def RegisterPy(): try: reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try: reg = CreateKey(HKEY_CURRENT_USER, regpath) SetValue(reg, installkey, REG_SZ, installpath) SetValue(reg, pythonkey, REG_SZ, pythonpath) CloseKey(reg) except: print ("*** Unable to register!") return print (" Python", version, "is now registered!") return if (QueryValue(reg, installkey) == installpath and QueryValue(reg, pythonkey) == pythonpath): CloseKey(reg) print ("=== Python", version, "is already registered!") return CloseKey(reg) print ("*** Unable to register!") print ("*** You probably have another Python installation!")if __name__ == "__main__": RegisterPy()
阅读全文
0 0
- Python Windows中将Python添加到注册表中
- 脚本执行 把python添加到 注册表
- python操作windows注册表
- python 中将一个函数的输出写入到文件中
- python 操纵 控制 windows 注册表
- python中将源码加入系统环境中
- python中将正则过滤的内容输出写入到文件中
- 使用Python访问Windows的注册表
- python在windows下读写注册表
- python _winreg 读取 注册表 windows error 5
- windows中将绿色程序添加到鼠标右键
- 如何利用python从mysql中将数据导出到excel
- 添加 module 到 python 的 path 中(自动找到module)
- 在Ubuntu 16.04 中将应用添加到系统服务中
- 将python 添加进64位win7 的注册表
- 在Windows中将Nachos导入到Eclipse中
- Windows中将生成的文件复制到指定目录中
- windows中安装python
- 基础公共显示控件演示
- 从上百幅架构图中学得半点大型网站建设经验(上)
- 基本数据结构――堆的基本概念及其操作
- Lintcode131 Building Outline solution 题解
- Eclipse中使用Maven创建Web项目index.jsp报错
- Python Windows中将Python添加到注册表中
- es6之一
- Android release keystore 找不到?原来它们就是.jks文件!
- 404. Sum of Left Leaves (二叉树)
- mac_命令行下控制Wi-Fi
- 机房开始篇
- JSON.stringify()将 JavaScript 对象转换为字符串。
- 写程序学ML:决策树算法原理及实现(四)
- C++标准库