for /f "skip=2 tokens=2 delims=REG_SZ " %%a in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do set OOS=%%a
echo %OOS%
结果:“ Windows 10 Pro” 如何得到“Windows 10 Pro”而不要前面的空格呢? 不要set OOS=%%a %%b %%c这样的
因为:“ Windows 10 Pro” 可能是“ Windows Server 2016 Datacenter”
下为reg QUERY中一个例子
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
ProductName REG_SZ Windows 10 Pro
搞定了
for /f "skip=2 delims=" %%a in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do set OOS=%%a
set OOS=%OOS:~29%
echo %OOS%
pause
@echo off
for /f "skip=2 delims=" %%a in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do (
set OOS=%%a
)
set OOS=%OOS:~29%
echo %OOS%
@echo off
for /f "skip=2 delims=" %%a in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do (
set OOS=%%a
)
set OOS=%OOS:~29%
echo %OOS%
详情回复
发表于 2017-3-10 14:26