Your question is not clear. For what are you asked to click OK?
You have too few comments in your code to clarify your intention. put some more comments so we can try to help you.
[signature deleted by host]
According to the documentation for encryptUsingPolicy(), manual interaction may be necessary, depending on the policy used. You might look at the policies if you find ways to reduce interaction.
As an alternative, you might look at third party products which would provide encryption etc. (such as the ones from Appligent, which are command line utilities, and are therefore more suitable to be embedded in a process).