2013-09-16 48 views
0

我有执行PowerShell脚本的.bat文件。他们在Task Scheduler中运行正常,或者在我自己运行批处理文件时运行良好,但是当我从Outlook(无论是从VBA脚本还是使用规则)运行它们时 - 它们只是立即退出而没有完成。从Outlook启动时批处理文件失败

,就像这样:

* PowerShell的 - 文件C:\用户\ tenba1 \文档\脚本\ Account_Recon.ps1 *

我也试过这样:

* 呼叫PowerShell -file C:\ Users \ tenba1 \ Documents \ Scripts \ Account_Recon.ps1 *

任何想法为什么会发生这种情况?

+0

也显示批次。 – Endoro

+0

抱歉,不确定你的意思。 – user2725402

+1

更新: 通过默认情况下Powershell的执行策略设置为Restricted,这意味着您无法以批处理模式运行任何脚本。 将批处理文件更改为此并且它工作: ** Powershell.exe -ExecutionPolicy Bypass -File C:\ Users \ tenba1 \ Documents \ Scripts \ Account_Recon.ps1 ** – user2725402

回答

0

您需要在脚本调用中取消限制您的执行策略。

Powershell.exe -ExecutionPolicy Unrestricted -File filedir\filename.ps1 
相关问题