Link to home
Start Free TrialLog in
Avatar of sharepointDepot
sharepointDepotFlag for United Arab Emirates

asked on

output command prompt value in a variable

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
Avatar of NVIT
NVIT
Flag of United States of America image

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

Open in new window

Avatar of Bill Prew
Bill Prew

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

~bp
Avatar of sharepointDepot

ASKER

Hi NVIT,
It is saying acess is denied ? see attachment
8.jpg
@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
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
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
Hi Guys,
When I run  >>oa3tool.exe /validate - it displays exactly below output
https://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
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
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

ASKER CERTIFIED SOLUTION
Avatar of sharepointDepot
sharepointDepot
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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