|
本帖最后由 倒垃圾的歌者 于 2024-11-13 13:14 编辑
文件
检测当前系统版本.zip
(778 Bytes, 下载次数: 39)
代码如下:
- @echo off&(cd/d "%~dp0")& title 检测当前系统版本 & color f0 &(cacls "%SystemDrive%\System Volume Information" >nul 2>&1)||(start "" mshta vbscript:CreateObject^("Shell.Application"^).ShellExecute^("%~snx0"," %*","","runas",1^)^(window.close^)&exit /b)
- for /f "tokens=2* skip=2" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do set SystemVersion=%%b
- :: 检测并设置%SystemVersion%为"Windows XP"
- if /i "%SystemVersion:Windows XP=%" neq "%SystemVersion%" (
- set SystemVersion=XP
- )
- :: 检测并设置%SystemVersion%为"Windows 7"
- if /i "%SystemVersion:Windows 7=%" neq "%SystemVersion%" (
- set SystemVersion=7
- )
- :: 检测并设置%SystemVersion%为"Windows 8"
- if /i "%SystemVersion:Windows 8=%" neq "%SystemVersion%" (
- set SystemVersion=8
- )
- :: 检测并设置%SystemVersion%为"Windows 10"
- if /i "%SystemVersion:Windows 10=%" neq "%SystemVersion%" (
- set SystemVersion=10
- )
- :: 检测并设置%SystemVersion%为"Windows 11"
- if /i "%SystemVersion:Windows 11=%" neq "%SystemVersion%" (
- set SystemVersion=11
- )
- :: 显示结果
- goto Win%SystemVersion%
- :WinXP
- echo.
- echo 当前系统为Windows XP
- echo.
- pause
- :Win7
- echo.
- echo 当前系统为Windows 7
- echo.
- pause
- :Win8
- echo.
- echo 当前系统为Windows 8
- echo.
- pause
- :Win10
- echo.
- echo 当前系统为Windows 10
- echo.
- pause
- :Win11
- echo.
- echo 当前系统为Windows 11
- echo.
- pause
复制代码
由代码小浣熊优化
- @echo off
- color f0
- title 检测当前系统版本
- :: 以管理员权限运行
- if not %errorlevel%==0 (
- start "" mshta vbscript:CreateObject^("Shell.Application"^).ShellExecute^("%~snx0"," %*","","runas",1^)^(window.close^)&exit /b
- )
- :: 获取系统版本信息
- for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do set "SystemVersion=%%b"
- :: 检测并设置%SystemVersion%为"Windows XP"
- if /i "%SystemVersion:Windows XP=%" neq "%SystemVersion%" set "SystemVersion=XP"
- :: 检测并设置%SystemVersion%为"Windows 7"
- if /i "%SystemVersion:Windows 7=%" neq "%SystemVersion%" set "SystemVersion=7"
- :: 检测并设置%SystemVersion%为"Windows 8"
- if /i "%SystemVersion:Windows 8=%" neq "%SystemVersion%" set "SystemVersion=8"
- :: 检测并设置%SystemVersion%为"Windows 8.1"
- if /i "%SystemVersion:Windows 8.1=%" neq "%SystemVersion%" set "SystemVersion=8.1"
- :: 检测并设置%SystemVersion%为"Windows 10"
- if /i "%SystemVersion:Windows 10=%" neq "%SystemVersion%" set "SystemVersion=10"
- :: 检测并设置%SystemVersion%为"Windows 11"
- if /i "%SystemVersion:Windows 11=%" neq "%SystemVersion%" set "SystemVersion=11"
- :: 根据系统版本跳转到相应的输出信息
- goto Win%SystemVersion%
- :WinXP
- echo.
- echo 当前系统为Windows XP
- echo.
- pause
- exit /b
- :Win7
- echo.
- echo 当前系统为Windows 7
- echo.
- pause
- exit /b
- :Win8
- echo.
- echo 当前系统为Windows 8
- echo.
- pause
- exit /b
- :Win8.1
- echo.
- echo 当前系统为Windows 8.1
- echo.
- pause
- exit /b
- :Win10
- echo.
- echo 当前系统为Windows 10
- echo.
- pause
- exit /b
- :Win11
- echo.
- echo 当前系统为Windows 11
- echo.
- pause
- exit /b
复制代码
检测当前系统版本-代码小浣熊优化.zip
(808 Bytes, 下载次数: 38)
参考@wangyibin、@1G空间100元 最终优化版本
- @echo off
- cd /d "%~dp0"
- color f0
- title 检测当前系统版本
- :: 以管理员权限运行
- if not %errorlevel%==0 (
- start "" mshta vbscript:CreateObject^("Shell.Application"^).ShellExecute^("%~snx0"," %*","","runas",1^)^(window.close^)&exit /b
- )
- :: 获取系统版本信息
- for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do set "SystemVersion=%%b"
- for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CurrentBuild"') do set "BuildVersion=%%b"
- for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "EditionID"') do set "Product-type=%%b"
- for /f "tokens=3" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR"') do set "UBR=%%i"
- set /a "UBR10=%UBR%"
- :: 判断系统为32位还是64位
- wmic os get osarchitecture | find /i "64" >nul && set "bit=x64" || set "bit=x32"
- :: 检查系统版本,确保精确匹配
- if /i "%SystemVersion:Windows XP=%" neq "%SystemVersion%" (goto :WinXP)
- if /i "%SystemVersion:Windows 7=%" neq "%SystemVersion%" (goto :Win7)
- if /i "%SystemVersion:Windows 8=%" neq "!SystemVersion!" (goto :Win8)
- if /i "%SystemVersion:Windows 8.1=%" neq "%SystemVersion%" (goto :Win8.1)
- if /i "%SystemVersion:Windows 10=%" neq "%SystemVersion%" (
- if %BuildVersion% GEQ 22000 goto :Win11
- goto :Win10
- )
- :: 未检测到已知版本时的处理
- echo 无法检测到已知的 Windows 版本。
- goto :End
- :WinXP
- echo.
- echo 当前系统为 Windows XP %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :Win7
- echo.
- echo 当前系统为 Windows 7 %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :Win8
- echo.
- echo 当前系统为 Windows 8 %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :Win8.1
- echo.
- echo 当前系统为 Windows 8.1 %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :Win10
- echo.
- echo 当前系统为 Windows 10 %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :Win11
- echo.
- echo 当前系统为 Windows 11 %Product-type% %BuildVersion%.%UBR10% %bit%
- echo.
- goto :End
- :End
- pause
- exit /b
复制代码
文件
检测当前系统版本-最终版本.zip
(1001 Bytes, 下载次数: 19)
有没有人测试一下是否有用?
Windows 10已测试成功!
如果你觉得有用就发个Windows X系统通过
|
|