Avatar of sharepointDepot
sharepointDepot
Flag 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
Microsoft DOSWindows OSMicrosoft Server OSWindows 8

Avatar of undefined
Last Comment
sharepointDepot

8/22/2022 - Mon
NVIT

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

Open in new window

Bill Prew

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

~bp
sharepointDepot

ASKER
Hi NVIT,
It is saying acess is denied ? see attachment
8.jpg
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Bill Prew

@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 Prew

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 Prew

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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
sharepointDepot

ASKER
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
Bill Prew

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
NVIT

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

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
sharepointDepot

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sharepointDepot

ASKER
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