Answer password to keytool in batch files

ZenfStor picture ZenfStor · Sep 27, 2011 · Viewed 13.9k times · Source

i need use keytool and jarsigner to sign a lot o files here in many folders.
Each time i start sign theses files i need delete the .cert and keystore file to recreate it.
Im on development enviroment and using fake passwd to sign it, after application working the infra people will take care of sign it, i havent access to real certificates.
When i was typing and the keytool -import ....... ,after enter, ask for password i simply type it but in batch it become a problem.
Im on windows 7 here.
I was tried keytool -import ....... < passHere and keytool -import ....... | passHere, too but it doesn't work.
I want turn sign most automatic possible.
There is someone telling about use it programatically here but i simply need it on a bat file.
The password is a fixed value inside batch file.
There is a way to give passwd inline to keytool?
Is possible set an enviroment variable in 'run time' to feed keytool password? how do it ?
There is a way to give passwd inside bath to keytool? I see this but dont help because i'm not a asm developer and not sure if it match problem and im wondering if there is something more simple.

Thanks

Answer

hellerpop picture hellerpop · Oct 29, 2012

This command works for me (tested it with keytool from jdk 1.6.0.24):

keytool -import -noprompt -file PathToCertificate -alias SomeCertificateAlias -keystore PathToKeyStore -storepass KeyStorePassword