如何在dos批处理文件中设置y的默认答案

时间:2022-09-30 07:07:05

I try to write a batch file to use Gpg4win to encrypt file. here is what inside the batch file:

我尝试编写批处理文件以使用Gpg4win加密文件。这是批处理文件中的内容:

gpg2 --recipient client_certiticate_name -e test.txt 

because of client certificate problem, I get following message:

由于客户端证书问题,我得到以下消息:

"It is NOT certain that the key belongs to the person named in the user ID. If you really know what you are doing, you may answer the next question with yes. Use this key anyway? (y/N)"

“不确定密钥是否属于用户ID中指定的人。如果您真的知道自己在做什么,可以回答下一个问题。无论如何都要使用此密钥?(是/否)”

So, I have to enter y all the time. There is any way I can put the answer in the batch file?

所以,我必须一直输入y。有什么办法可以把答案放在批处理文件中吗?

Thanks in advance

提前致谢

4 个解决方案

#1


0  

put the answers in a text file named a.txt and run your bat like this:

将答案放在一个名为a.txt的文本文件中并像这样运行你的蝙蝠:

xxx.bat < a.txt

xxx.bat

#2


0  

Piping the Y into the command usually works. Though some executables clear the input buffer before asking for input.

将Y管道插入命令通常有效。虽然一些可执行文件在请求输入之前清除了输入缓冲区。

echo Y|gpg2 --recipient client_certiticate_name -e test.txt

#3


0  

I create a private key and certify the client certificate.

我创建了一个私钥并验证了客户端证书。

#4


0  

Try encrypting with one of these

尝试使用其中一个加密

gpg2 --recipient client_certiticate_name -e -yes test.txt 

or

gpg2 --recipient client_certiticate_name -e -always-trust test.txt 

Just add either -yes or -always-trust.

只需添加-yes或-always-trust即可。

#1


0  

put the answers in a text file named a.txt and run your bat like this:

将答案放在一个名为a.txt的文本文件中并像这样运行你的蝙蝠:

xxx.bat < a.txt

xxx.bat

#2


0  

Piping the Y into the command usually works. Though some executables clear the input buffer before asking for input.

将Y管道插入命令通常有效。虽然一些可执行文件在请求输入之前清除了输入缓冲区。

echo Y|gpg2 --recipient client_certiticate_name -e test.txt

#3


0  

I create a private key and certify the client certificate.

我创建了一个私钥并验证了客户端证书。

#4


0  

Try encrypting with one of these

尝试使用其中一个加密

gpg2 --recipient client_certiticate_name -e -yes test.txt 

or

gpg2 --recipient client_certiticate_name -e -always-trust test.txt 

Just add either -yes or -always-trust.

只需添加-yes或-always-trust即可。