<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: получение ProductKey установленной Windows]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5197&amp;type=atom" />
	<updated>2010-11-21T16:58:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5197</id>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: получение ProductKey установленной Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42034#p42034" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>@echo off
setlocal enabledelayedexpansion

for /f &quot;tokens=3&quot; %%i in (&#039;reg.exe query &quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion&quot; /v DigitalProductId&#039;) do (
    set x=%%~i
)

for /l %%z in (104, 2, 132) do (
    set /a array[%%z]=0x!x:~%%z,2!
)

call :GetKey
echo ProductKey: %GetKey%
rem pause &gt;nul

endlocal
exit /b 0

:GetKey
    setlocal enabledelayedexpansion
    set out=%~0
    set pc=BCDFGHJKMPQRTVWXY2346789
    set x=0
    for /l %%i in (0, 1, 28) do (
        if !x! gtr 28 goto :Break

        set a=0

        for /l %%j in (132, -2, 104) do (
            set /a a=array[%%j] + !a! * 256
            set /a array[%%j]=&quot;( !a! / 24 ) &amp; 255&quot;
            set /a a%%=24
            set /a n=%%j
        )

        for %%z in (!a!) do set key=!pc:~%%z,1!!key!
        set /a f=&quot;( !x! + 2 ) %% 6&quot;

        if !f! equ 0 if !x! lss 28 (
            set /a x+=1
            set key=-!key!
        )

        &lt;nul set /p sTemp=.
        set /a x+=1
    )
:Break
    echo.
    endlocal &amp; set %out:~1%=%key%
    exit /b</code></pre></div><p>Требуется наличие «reg.exe» в «PATH» (актуально для версий ниже Windows XP). См. также: <a href="http://forum.script-coding.com/viewtopic.php?id=522">VBScript: Получение ProductKey установленных Windows и MS Office</a>.</p><p>Автор идеи — <strong>smaharbA</strong>.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-11-21T16:58:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42034#p42034</id>
		</entry>
</feed>
