【问题标题】:Powershell Command in Windows Server 2019 Task Scheduler?Windows Server 2019 任务计划程序中的 Powershell 命令?
【发布时间】:2020-05-01 14:36:16
【问题描述】:

我正在尝试安排一个 Powershell 任务在 Windows 启动后自动启动(以在崩溃或维护的情况下重新启动进程)。我对 Powershell 的了解非常有限,但是当我要手动启动任务时,我需要转到资源管理器中的文件夹,然后从那里打开 Powershell,默认为“PS C:\Users{{username}}\Documents \fso\fso> " 然后我在其中输入 "./watchdog.bat"。在尝试设置任务计划程序时,它似乎正在寻找一个我不知道的 .ps1 文件。有人介意帮我解决这个问题吗?

提前非常感谢:)

【问题讨论】:

  • 您是否尝试将任务操作的“工作目录”设置为C:\Users{{username}}\Documents\fso\fso
  • 我不太确定是否诚实。根据我通过 Google 搜索和与我的类似帖子找到的内容,我创建了一个任务“动作”来“启动程序”。对于我已经完成“powershell.exe”的程序,然后将 C:\Users\{{username}}\Documents\fso\fso 放在“Start In”中。那会是正确的吗?我不确定在哪里输入命令“./watchdog.bat”。这会是争论吗?
  • 太好了,那么您只需在“添加参数”字段中添加要运行的命令或文件,输入-Command './watchdog.bat'-File "C:\path\to\script.ps1",其中script.ps1 将是一个powershell 脚本打电话给watchdog.bat
  • 你是救生员。非常感谢!
  • 您可以将其发布为关闭此问题的答案。

标签: powershell azure-functions scheduled-tasks


【解决方案1】:

感谢 Mathias R. Jessen 的帮助,

解决方案是在“添加参数”字段中添加要运行的命令或文件,输入-Command './watchdog.bat'-File "C:\path\to\script.ps1",其中script.ps1 将是调用watchdog.bat 的powershell 脚本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-28
    • 2013-04-05
    • 2017-08-22
    • 2014-09-15
    • 2013-11-07
    • 2020-03-07
    • 1970-01-01
    • 2016-01-30
    相关资源
    最近更新 更多