使用wmic
命令时,可以使用 指定区域设置
/locale:ms_409
,即美国英语。我使用的是德语版的 Windows XP,在使用 查询信息时会显示一些本地化值baseboard
。例如,使用以下命令时,区域设置似乎没有任何区别。 的值Tag
以英语显示,而 的值Caption
以德语显示。您如何在 中使用区域设置wmic
?是否不能以英语(我猜是)原始语言来显示这些本地化值?如果不能,那么指定区域设置的可能性有什么用处?
wmic:root\cli>context
NAMESPACE : root\cimv2
ROLE : root\cli
NODE(S) : COMP
IMPLEVEL : IMPERSONATE
[AUTHORITY : N/A]
AUTHLEVEL : PKTPRIVACY
LOCALE : ms_407
...
wmic:root\cli>baseboard get caption, tag
Caption Tag
Hauptplatine Base Board
wmic:root\cli>/locale:ms_409 baseboard get caption, tag
Caption Tag
Hauptplatine Base Board
wmic:root\cli>context
NAMESPACE : root\cimv2
ROLE : root\cli
NODE(S) : COMP
IMPLEVEL : IMPERSONATE
[AUTHORITY : N/A]
AUTHLEVEL : PKTPRIVACY
LOCALE : ms_409
答案1
您如何使用语言环境wmic
?仅当 中列出了特定语言时,您才可以获取本地化值wmic /namespace:\\root\cli path __NAMESPACE
,例如如下所示:
结果(在我的 Windows 上,略作修改):437654test.bat
MS_409 US Caption Tag Base Board Base Board MS_408 Greek Caption Tag Βασική πλακέτα Base Board MS_419 Russian Caption Tag Основная плата Base Board MS_405 Czech Caption Tag Základní deska Base Board
解释:应用于/trace:on
诊断问题;请注意,我的 Windows(默认MS_409
)中没有安装德语(MS_407
):
wmic /trace:on /locale:ms_407 baseboard get caption,tag
SUCCESS: IWbemLocator::ConnectServer(L"root\cli", NULL, NULL, L"ms_407", 0L, L"", NULL, -)
Line: 143 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
SUCCESS: CoSetProxyBlanket(-, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_NONE, NULL, 6, 3, -, EOAC_NONE)
Line: 162 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
FAIL: IWbemLocator::ConnectServer(L"root\cli\ms_407 not found. Connecting to ms_409", NULL, NULL, L"ms_407", 0L, L"", NULL, -)
Line: 2491 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
SUCCESS: IWbemLocator::ConnectServer(L"root\cli\ms_407", NULL, NULL, L"ms_409", 0L, L"", NULL, -)
Line: 2524 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
… (truncated) …
此外,只有可本地化属性已本地化。该Tag
属性无法本地化,因为它具有关键限定符在里面Win32_BaseBoard 类
SUCCESS: IWbemClassObject::Get(L"Name", 0, -, 0, 0)
Line: 1751 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
Result: Tag
SUCCESS: IWbemClassObject::Get(L"Derivation", 0, -, 0, 0)
Line: 1767 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
Result: Tag
SUCCESS: IWbemClassObject::Get(L"Description", 0,-, 0, 0)
Line: 1923 File: onecore\admin\wmi\wbem\tools\wmic\cmdalias.cpp
Result: The Tag property uniquely identifies the base board of the system.
剧本: type 437654test.bat
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
for /F "tokens=1" %%G in ('
wmic /namespace:\\root\cli path __NAMESPACE get Name /Value
') do for /F "tokens=1,* delims==" %%g in ("%%~G") do (
wmic /namespace:\\root\cli path __NAMESPACE where "%%~g='%%~h'"|findstr "%%~h"
call :namespace "%%~h"
)
:endlocal
ENDLOCAL
goto :eof
:namespace
REM parameter %1 = namespace
set "_ns=%~1"
set "_lc=%_ns:~3%"
set "_rk=HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00000"
for /F "tokens=3*" %%P in ('
reg query "%_rk%%_lc%" -v "Layout Text" ^|findstr /I "Layout.Text"
') do echo %%Q
wmic /locale:%_ns% baseboard get Caption,Tag
REM ,Description,Name
goto :eof