使用节点运行脚本的计划任务不起作用

时间:2018-05-31 12:30:34

标签: javascript node.js windows scheduled-tasks

我按照本教程安排了使用node运行脚本的任务:

https://eddyerburgh.me/run-a-node-script-with-windows-task-scheduler

我打开电脑,因此它可以执行脚本,但是当我看到它是否执行时,只有一个cmd.exe实例打开,任务没有执行脚本。

以下是我配置动作的方式:

Program/Script - C:\WINDOWS\system32\cmd.exe

Arguments - --a -i -c "cd C:\Users\xxxxx\Desktop\folder; node script.js"

还有另一种方法吗?

2 个答案:

答案 0 :(得分:1)

我已经设法通过制作这样的.bat文件来实现它:

if not "%minimized%"=="" goto :minimized
set minimized=true
@echo off
cd "<folder where the script is">

start /min cmd /C "node <the script you want to execute>"
goto :EOF
:minimized

然后您可以安排执行.bat文件。

答案 1 :(得分:1)

您不需要所有这些额外的参数。只需使用以下设置:

程序/脚本node(如果不在您的PATH中,则为"C:\\Proram Files\node\node.exe"
参数: C:\\Users\user\folder\script.js

它将起作用。

enter image description here