我有一个使用subprocess.call()
来调用openssl
的python脚本,它从命令行运行良好。
但是,当我运行Windows任务计划时,作业将失败并显示
Winrror2:找不到指定的文件
删除subprocess.call()
后,同一作业在任务计划程序中运行良好。
我尝试用简单的openssl
副本替换cp
命令,但它仍然显示相同的错误。
注意:
1.我正在使用python v3.6
2.作业设置为使用具有最高权限的SYSTEM帐户运行。
搜索网后,我也包括shell=True
;没运气。唯一的区别是 - 它抑制了日志中的错误消息
以下是代码的一部分:
infilepath = str(r'C:\Test\filename.txt.bin')
outfilepath = str(r'C:\Test\filename.txt')
deckeyfile = str(r'C:\Test\decryptionkey.key')
#decrypt the file
try:
subprocess.call(["openssl", "cms", "-decrypt", "-inform", "DER", "-in", infilepath, "-binary", "-inkey", deckeyfile, "-out", outfilepath], shell=True)
#subprocess.call(["cp", infilepath, outfilepath])
decryptcount += 1
except Exception as e:
module_logger.error("Failed to decrypt with error: %s", str(e), exc_info = True)
errorcount += 1`