【问题标题】:Batch File fails when launched from Outlook从 Outlook 启动时批处理文件失败
【发布时间】:2013-09-20 18:56:25
【问题描述】:

我有执行 PowerShell 脚本的 .bat 文件。它们在任务计划程序或我自己运行批处理文件时运行良好,但是当我从 Outlook(从 VBA 脚本或使用规则)运行它们时 - 它们只是立即退出而没有完成。

它们看起来像这样:

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

我也试过这个:

*调用 PowerShell -file C:\Users\tenba1\Documents\Scripts\Account_Recon.ps1*

知道为什么会这样吗?

【问题讨论】:

  • 抱歉,不确定您的意思。
  • 更新:发现默认情况下,Powershell 的执行策略设置为 Restricted,这意味着您不能在批处理模式下运行任何脚本。将批处理文件更改为此并且它工作:Powershell.exe -ExecutionPolicy Bypass -File C:\Users\tenba1\Documents\Scripts\Account_Recon.ps1

标签: batch-file outlook-2010


【解决方案1】:

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

Powershell.exe -ExecutionPolicy Unrestricted -File filedir\filename.ps1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-22
    • 2021-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-13
    相关资源
    最近更新 更多