博客
关于我
Windows批处理自动检测、安装Python
阅读量:292 次
发布时间:2019-03-01

本文共 1279 字,大约阅读时间需要 4 分钟。

原理及问题:

  1. 使用注册表检测Python是否安装,检测注册表项hklm\software\Python\pythoncore是否存在指定版本信息。经试验发现该注册表项对于较早的安装包无效。
  2. 使用py -3.7 --version检测Python解释器是否正常运行,较早的安装包或者未安装python启动器将检测失败。
  3. 采用静默模式安装Python,针对所有用户安装,将Python信息加入环境变量path中。
  4. 安装文件必须与批处理文件处于同一目录
@ECHO OFFrem  检测注册表中是否有Python3.7信息。echo ----------------------------------echo 检测注册表……reg query "hklm\software\Python\pythoncore\3.7" >nul 2>nulif %errorlevel%==0 (echo 注册表检测到指定版本Python & GOTO check_python) else (echo 注册表未检测到指定版本Python!开始安装Python3.7…… & goto install_python):uninstall_pythonecho 正在卸载Python!请稍候……python-3.7.6-amd64.exe /quiet /uninstallecho 卸载Python完成!:check_pythonrem 检测运行指定版本Python是否成功。echo ----------------------------------echo 检测指定版本Python运行状况……py -3.7 --version  >nul 2>nulif %errorlevel%==0 (echo Python运行正常! & goto check_pip) else (echo Python运行异常!)pause:check_piprem 检测运行pip是否成功。echo ----------------------------------echo 检测pip运行状况……@for /f "tokens=1" %%i in ('pip --version ^| findstr /C:"pip"')  do ^set PIPVER=%%i@if "%PIPVER%" == "pip" (@echo Pip运行正常!) else echo (Pip运行异常!)pausegoto:eof:install_pythonrem 采用静默模式安装Python。echo ----------------------------------echo 开始安装Python,请稍候……python-3.7.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1if %errorlevel%==0 (echo Python3.7安装成功!& goto check_python) else echo (Python安装失败!)

转载地址:http://yjmx.baihongyu.com/

你可能感兴趣的文章
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
Nginx/Apache反向代理
查看>>
Nginx: 413 – Request Entity Too Large Error and Solution
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Nginx、HAProxy、LVS
查看>>
nginx一些重要配置说明
查看>>
Nginx下配置codeigniter框架方法
查看>>
Nginx与Tengine安装和使用以及配置健康节点检测
查看>>
Nginx中使用expires指令实现配置浏览器缓存
查看>>
Nginx中使用keepalive实现保持上游长连接实现提高吞吐量示例与测试
查看>>
Nginx中实现流量控制(限制给定时间内HTTP请求的数量)示例
查看>>