getting windows product key from bios
<p>I'm attempting to make a batch script to pull the windows product key from BIOS so the computer can be properly activated in a production environment.</p>

<p>The command I am running to get the key is <code>wmic path SoftwareLicensingService get OA3xOriginalProductKey &gt; text.txt</code></p>

<p>which creates a text file called text.txt which contains this:</p>

<pre><code>OA3xOriginalProductKey         
xxxxx-xxxxx-xxxxx-xxxxx-xxxxx 
</code></pre>

<p>(Note some random spaces in there after each line)
The problem is I need JUST the <code>xxxxx-xxxxx-xxxxx-xxxxx-xxxxx</code> part, but I am having a terrible time doing that.</p>

<p>I have tried the following:</p>

<p><code>for /F "skip=10 delims=" %%i in (text.txt) do echo %%i</code></p>

<p><code>for /f "tokens=1*delims=:" %%G in ('findstr /n "^" text.txt') do if %%G equ 2 echo %%H</code></p>

<pre><code>for /f "tokens=*" %%a in (text.txt) do call :processline %%a

:processline
echo line=%*
</code></pre>

<p>and last but not least</p>

<pre><code>for /F "tokens=2" %%i in (text.txt) do echo %%i %%j %%k
</code></pre>

<p>As I said I am having a terrible time and am very much a noob with for /f - I have no idea where I am going wrong or what to do.</p>