简体   繁体   English

如何以编程方式检查我是否正在运行Windows 8.1?

[英]How can I programatically check that I am running Windows 8.1?

如何使用cmd.exe或PowerShell以编程方式检查我是否正在运行Windows 8.1?

Powershell 电源外壳

get-wmiobject win32_operatingsystem will return several properties you can use to check the OS. get-wmiobject win32_operatingsystem将返回几个可用于检查操作系统的属性。

get-wmiobject win32_operatingsystem|select-object name,caption,buildnumber,version|format-list

name        : Microsoft Windows 8.1 Enterprise|C:\WINDOWS|\Device\Harddisk0\Partition2
caption     : Microsoft Windows 8.1 Enterprise
buildnumber : 9600
version     : 6.3.9600

CMD CMD

wmic os get caption /value|find "="

to put it into a variable: 将其放入变量中:

for /f %%i in ('wmic os get caption /value^|find "="') do set version=%%i

Another method using PowerShell: 使用PowerShell的另一种方法:

(Get-Command -Name $env:windir\system32\ntoskrnl.exe).FileVersionInfo.FileVersion -match '6.3.9600';

This command returns $true or $false . 此命令返回$true$false To be honest, alroc's is the ideal solution, in my opinion. 老实说,我认为alroc是理想的解决方案。 This is just an alternative. 这只是一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式从另一个程序中关闭Windows中运行的SPECIFIC Java应用程序? - How can I programatically close a SPECIFIC java application running in windows from within another program? 如何通过P / Invoking在Windows 8 / 8.1中以编程方式更改视觉主题? - How do I change a visual theme programatically in Windows 8/8.1 by P/Invoking? 如何加快Windows Phone 8.1模拟器的速度? - How can I speed up the Windows Phone 8.1 Emulator? 如何从Windows 8.1读取嵌入式控制器版本? - how can I read embedded controller version from Windows 8.1? 如何从 Windows 8.1 中的批处理文件设置背景? - How can i set a background from a batch file in windows 8.1? 如何为Windows 8.1应用程序创建嵌套的TreeView? - How can I create a nested TreeView for Windows 8.1 app? 如何在桌面应用程序中检测Windows 8.1 - How can I detect Windows 8.1 in a Desktop application 如果我在Linux OS上运行,如何使用gcc g ++编译Windows二进制文件? - How can I use gcc g++ to compile a windows binary if I am running on a Linux OS? 如何在 Windows 10 及更高版本中以编程方式刷新任务栏? - How can I refresh the Taskbar programatically in Windows 10 and higher? 如何检查我正在运行哪个版本的 WSL2? - How to check which build of WSL2 am I running?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM