2013-09-16 47 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 
相關問題