You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看Windows 10版本?编写批处理按版本区间判断是否安装x.exe

Hey there, let's tackle your two questions step by step:

一、如何查看已安装的Windows 10版本?

Here are a few straightforward ways to check your Windows 10 version details:

  • Via System Settings: Open Settings → System → About, then look under the Windows specifications section. You'll find both the version number (e.g., 1607) and the internal build number (e.g., 14393) here.
  • Using Command Prompt: Press Win+R, type cmd and hit Enter. You can either run winver (a pop-up window will show your full version info) or execute systeminfo | findstr /B /C:"OS Version" to get the details directly in the command line.
  • Through Registry Editor: Press Win+R, type regedit to launch the registry. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion, then check the ReleaseId (for version labels like 1607) and CurrentBuild (for build numbers like 14393) values.
二、编写批处理文件检测Windows 10版本并执行安装逻辑

Based on your requirement — install x.exe only if the Windows 10 version is between 1607 (Redstone 1) and RS3 (1709, before RS4), and skip installation for RS4 and later — we can use the internal build number for reliable detection, since build numbers are unique and increment consistently with each version update.

First, here's the version-to-build mapping you provided for reference:

threshold 1 1507 10240、threshold 2 1511 10586、redstone 1 1607 14393、redstone 2 1703 15063、redstone 3 1709 16299、redstone 4 1803 17134、redstone 5 1809 17650

We need to check if the build number falls between 14393 (1607) and 16299 (1709, inclusive). Here's the batch script to implement this logic:

@echo off
setlocal enabledelayedexpansion

:: Retrieve the Windows internal build number
for /f "tokens=2 delims==" %%a in ('wmic os get buildnumber /value') do (
    set "BuildNumber=%%a"
)

:: Remove any extra spaces from the build number (WMIC output may have trailing spaces)
set "BuildNumber=!BuildNumber: =!"

:: Check if build number is within the target range (1607 to RS3)
if !BuildNumber! geq 14393 if !BuildNumber! leq 16299 (
    echo Current Windows version meets the criteria, starting installation of x.exe...
    start "" "x.exe"
) else (
    echo Current Windows version is RS4 or newer, no need to install x.exe.
)

pause

Script Breakdown:

  • wmic os get buildnumber /value: This command efficiently fetches the system's build number, which is more reliable for version detection than the human-readable release ID.
  • The for /f loop parses the WMIC output to extract the build number, and we strip any extra spaces to avoid comparison errors.
  • The double if statement checks if the build number falls in our target range. If it does, the script launches x.exe; otherwise, it prints a message stating installation isn't required.
  • start "" "x.exe": This ensures x.exe launches correctly even if its file path contains spaces.

内容的提问来源于stack exchange,提问作者Ege Gökhan Gürkan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:11:51