Save second line of a command in Prompt

Asked

Viewed 325 times

1

I need to save the second line of a command in Windows CMD, when using WMIC, it returns the product key in the second line, showing any message in the first. I need to store this line in a variable, to apply in the SLMGR command.

Comando:<br>

wmic path softwareLicensingService get OA3xOriginalProductKey 

Mensagem de retorno:<br>

Oa3xoriginalproductkey
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (precise of that line)

Someone knows how to do it??


He only catches the first line doing it. I only need the second line containing the key, because the slmgr recognizes only it, any other character will present error.

1 answer

1

Run the command at the MS-Dos prompt normally by adding > arquivo at the end of the command for the system to save the output in that file, so:

wmic path softwareLicensingService get OA3xOriginalProductKey > saida.txt

Then read the text file and process the lines that are of interest to you.

  • But in that case, how do I read only that second line, inside a bat?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.