python subprocess.call没有从Windows任务调度程序

时间:2017-12-29 21:13:29

标签: python python-3.x subprocess

我有一个使用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`

0 个答案:

没有答案