帮忙转下这个批处理代码为PECDM代码
2023-11-8 600

::获取产品名称(WMI/REG方法在所有情况下都不可靠,因此使用winbrand.dll的BrandingFormatString方法),形如Windows 10 企业版之类的

set winbuild=
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G

set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1) ;
set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False);
set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0);
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
set winos=
for /f "delims=" %%s in ('"powershell.exe %d1%"') do if not errorlevel 1 (echo %%s&&set winos=%%s)
echo "%winos%" | find /i "Windows" 1>nul || (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul') do set "winos=%%b"
if %winbuild% GEQ 22000 (
set winos=!winos:Windows 10=Windows 11!
)
)
echo %winos%
pause

收藏
点赞
分享
WINST
最新回复 (1)
  • avatar image
    anson4 2023-11-9

    如果从 winbrand.dll 获取是稳妥的,那为什么最后还要从注册表获取呢?

    单机计算
返回