Capture dynamic value as a variable
Posted: 21 Oct 2010 13:03
Hi,
I am using certutil command to dump the local certificate store and then have to pick up the skid value of the certificate. The output looks something like this
Key Id Hash(sha1): d8 51 cf b1 45 e7 cc a6 55 91 79 0b 6b e6 b1 ee e7 4f 81 f
Cert Hash(md5): c1 9c 56 23 d5 26 43 39 6b 6e 13 3d a1 0b 03 04
Cert Hash(sha1): 6f cd 7a c7 14 fe a6 fd fb 33 52 7d a9 b3 fb 27 0d 62 85 f8
CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID(24):
1f 35 d6 0e 91 61 df 29 b7 40 7f 91 58 4e 63 a9
CERT_SIGNATURE_HASH_PROP_ID(15):
4e 52 9b db dc cd 84 cb 95 f3 17 1f 39 b5 76 27 91 30 83 a3
CERT_KEY_IDENTIFIER_PROP_ID(20):
27 94 4d 86 38 ea a4 22 7c f2 17 bf 6d 0d 77 fe 10 c3 73 66
The above is only a part of output. I want to capture the string 27 94 4d 86 38 ea a4 22 7c f2 17 bf 6d 77 fe 10 c3 73 66 but it is dynamic in all machines. I have been able to use the for /f successfully to capture the line above it which is unique in every output using hte following command..
for /f %i in ('certutil -v -store My ^| findstr /i "_ID(20)"') do @echo %i
which gives me the output CERT_KEY_IDENTIFIER_PROP_ID(20):
but that is not what i want, i want the line right after that as a variable.
Can someone help. Thanks
I am using certutil command to dump the local certificate store and then have to pick up the skid value of the certificate. The output looks something like this
Key Id Hash(sha1): d8 51 cf b1 45 e7 cc a6 55 91 79 0b 6b e6 b1 ee e7 4f 81 f
Cert Hash(md5): c1 9c 56 23 d5 26 43 39 6b 6e 13 3d a1 0b 03 04
Cert Hash(sha1): 6f cd 7a c7 14 fe a6 fd fb 33 52 7d a9 b3 fb 27 0d 62 85 f8
CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID(24):
1f 35 d6 0e 91 61 df 29 b7 40 7f 91 58 4e 63 a9
CERT_SIGNATURE_HASH_PROP_ID(15):
4e 52 9b db dc cd 84 cb 95 f3 17 1f 39 b5 76 27 91 30 83 a3
CERT_KEY_IDENTIFIER_PROP_ID(20):
27 94 4d 86 38 ea a4 22 7c f2 17 bf 6d 0d 77 fe 10 c3 73 66
The above is only a part of output. I want to capture the string 27 94 4d 86 38 ea a4 22 7c f2 17 bf 6d 77 fe 10 c3 73 66 but it is dynamic in all machines. I have been able to use the for /f successfully to capture the line above it which is unique in every output using hte following command..
for /f %i in ('certutil -v -store My ^| findstr /i "_ID(20)"') do @echo %i
which gives me the output CERT_KEY_IDENTIFIER_PROP_ID(20):
but that is not what i want, i want the line right after that as a variable.
Can someone help. Thanks