output  command prompt value in a variable

sharepointDepot
sharepointDepot used Ask the Experts™
on
Hi,
I have a .exe at this path C:\Program Files\windows kits\8.1\assessment and deployment kit\deployment tools\x86\licensing\oa30\

after that I type   following command .... oa3tool.exe /validate

Now - how can I catch the output into a variable say-  $HexData for further output ?

ref- http://www.reddit.com/r/sysadmin/comments/31762r/os_imagecloning_help/

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NVITEnd-user support

Commented:
oa3tool.exe /validate > catch.txt
SET /p $HexData=<catch.txt

Open in new window

Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
What scripting will you be working with, Powershell, DOS, etc?

~bp

Author

Commented:
Hi NVIT,
It is saying acess is denied ? see attachment
8.jpg
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
@sharepointDepot

Your default directory when you ran the oa3tool.exe was under the program files folders, and Windows will typically protect that whole tree from writing for normal users.  You can either run the script in elevated admin mode, or probably better change the temp file location to a writable folder, like:

oa3tool.exe /validate > "%TEMP%\catch.txt"
SET /p $HexData=<"%TEMP%\catch.txt"

~bp
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Also, when you run the oa3tool.exe at a command prompt, what does it display?  Can you paste up a sample of the output?  And then specify exactly what value from the display you want placed in the variable?

~bp
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
One more item, on the web page you referenced in your question, there already is a Powershell script that can extract the information from the output and convert it.  Why not use that as is?

~bp

Author

Commented:
Hi Guys,
When I run  >>oa3tool.exe /validate - it displays exactly below output
http://www.experts-exchange.com/articles/13637/Where-is-my-Windows-8-Activation-Key.html 

but but but- i need to provide the path of .exe file which is - C:\Program Files\windows kits\8.1\assessment and deployment kit\deployment tools\x86\licensing\oa30\

So after the path-  i can write oa3tool.exe /validate  and will get output, but then i wanted to convert the output into decimal form, for that i wanted to hold it in some variable say $HexData

Thanks
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
That seems to be what the powershell script does on the page you originally referenced.  That would be much harder, if not impossible in DOS BAT script, but probably could be done in a VBS script.  

What are you planning to do with the value once you store it in a variable?

~bp
NVITEnd-user support

Commented:
Going the DOS route... this converts your variable $HexData to decimal 1000 and saves to $Dec:

set $HexData=000003E8
set /a $Dec=0x%$HexData%

Open in new window

Hi,
In the very end MASQ replied his suggestion -how to convert HEX-into key format, it make sense,
that makes a sense,
http://www.experts-exchange.com/articles/13637/Where-is-my-Windows-8-Activation-Key.html

other option is keyfinderplus tool,
thanks makes sense :)

Author

Commented:
because command prompt didnt run the way it is shown - so finally i directly posted to MSMQ-who is actually written the expert Exchange Article-so he replied-it make much sense, also there is alternate option of KeyFinder Plus tool, which is also helped

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial