zoukankan      html  css  js  c++  java
  • 批处理获取操作系统版本信息

     为了使得批处理命令获取更大的通用性,有时需要获取操作系统版本。今天为此搜了一些资料,网上的说法是Ver、注册表、WMI都可以。我研究了一下,发现还是Ver命令最为成熟,为此综合各家做法写下了下面一个批处理文件:

    @echo off
    cls
    
    ver | find "4.0." > NUL &&  goto win95  
    ver | find "4.10." > NUL &&  goto win98 
    ver | find "4.90." > NUL &&  goto win_me 
    ver | find "3.51." > NUL &&  goto win_Nt_3_5 
    ver | find "5.0." > NUL &&  goto win2000  
    ver | find "5.1." > NUL &&  goto win_xp  
    ver | find "5.2." > NUL &&  goto win2003  
    ver | find "6.0." > NUL &&  goto vista 
    ver | find "6.1." > NUL &&  goto win7  
    ver | find "6.2." > NUL &&  goto win8  
    
    :win95
    @echo           当前系统是:win95
    @echo ----------------------------------------
    goto end
    
    :win98
    @echo           当前系统是:win98
    @echo ----------------------------------------
    goto end
    
    :win_me
    @echo           当前系统是:win_me
    @echo ----------------------------------------
    goto end
    
    :win_Nt_3_5
    @echo           当前系统是:win NT 3.51
    @echo ----------------------------------------
    goto end
    
    :win2000
    @echo           当前系统是:win2000
    @echo ----------------------------------------
    goto end
    
    :win_xp
    @echo           当前系统是:WinXP
    @echo ----------------------------------------
    goto end
    
    :win2003
    @echo           当前系统是:win200
    @echo ----------------------------------------
    goto end
    
    :vista
    @echo           当前系统是:vista
    @echo ----------------------------------------
    goto end
    
    
    :win7
    @echo           当前系统是:win7
    @echo ----------------------------------------
    goto end
    
    :win8
    @echo           当前系统是:win8
    @echo ----------------------------------------
    goto end
    
    @echo           不能获取当前操作系统版本
    @echo ----------------------------------------
    
    :end
    pause


    下面是Windws 的主要版本列表:

                             

                 

           需要指出的是上面的批处理命令获取的操作系统版本的取自版本的前两位,获取的操作系统信息依然不够准确的,如上表所示,如Windows 8和Windows Server 2012的版本号都是6.2。所以在使用该批处理文件时需要注意这一点。

    参考文献:

    1. 批处理怎样判断操作系统的类型?
    1. OSVERSIONINFOEX structure (Windows)

    版权声明:本文为博主原创文章,未经博主允许不得转载。

     

    出处:http://blog.csdn.net/clever101/article/details/8453378

  • 相关阅读:
    通过ip找mac
    python开发总结
    iptables 通用语句
    运行pyqt4生成py文件增加代码
    re正则match、search、findall、finditer函数方法使用
    python list 字符串排序
    读取yaml文件小方法
    递归解析字典小方法
    assert 断言
    格式化字符串——初级% 和format
  • 原文地址:https://www.cnblogs.com/mq0036/p/4689962.html
Copyright © 2011-2022 走看看