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.
The command I am running to get the key is wmic path SoftwareLicensingService get OA3xOriginalProductKey > text.txt
which creates a text file called text.txt which contains this:
OA3xOriginalProductKey
xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
(Note some random spaces in there after each line)
The problem is I need JUST the xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
part, but I am having a terrible time doing that.
I have tried the following:
for /F "skip=10 delims=" %%i in (text.txt) do echo %%i
for /f "tokens=1*delims=:" %%G in ('findstr /n "^" text.txt') do if %%G equ 2 echo %%H
for /f "tokens=*" %%a in (text.txt) do call :processline %%a
:processline
echo line=%*
and last but not least
for /F "tokens=2" %%i in (text.txt) do echo %%i %%j %%k
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.