- Open Task Scheduler (
Win + R, taskschd.msc
) - Go to Actions > Create Basic Task…
- Enter a name and description
- Select trigger, e.g. Daily, One time, When I log on…
- Configure action:
- Type: Start a program
- Program/script:
npm
- Arguments:
run <script-name>
, e.g.run scrape
- Start in: directory where package.json is located, e.g.
C:\projects\hello
- Click Finish and test your action
Additionally, if you want the task to run in the background, make sure to select “Run whether user is logged on or not” under General properties for the task.