Board logo

标题: [系统相关] 批处理如何实现根据系统版本的不同执行不同操作? [打印本页]

作者: vikimono    时间: 2016-4-12 17:32     标题: 批处理如何实现根据系统版本的不同执行不同操作?

本帖最后由 pcl_test 于 2016-4-12 20:05 编辑

发现使用Ver不能区分比如Win7与Server 2008
准备使用wmic os get Caption,一只处理不好,有高手能帮忙解决不,谢谢了
作者: vikimono    时间: 2016-4-12 19:12

研究了下,好像成了
  1. @echo off
  2. for /f "skip=1 tokens=2,3,4,5,6" %%i in ('wmic os get Caption') do set win=%%i%%j%%k%%l
  3. echo %win%
  4. if /i %win%==Windows7Professional goto Win7
  5. if /i %Win%==WindowsServer2008R2 goto 2008R2
  6. goto End
  7. :Win7
  8. echo This is Windows 7 Professional English
  9. goto End
  10. :2008R2
  11. echo This is Windows Server 2008 R2 Enterprise
  12. :End
  13. pause
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2