I have a batch file called index.bat, which runs the following command:

node index.js

I tried to configure the file to be run on start up using schedule task manager and but it did not work as expected. What do I do?

  • 1
    When you say, does not work as expected, what does and what does not work? Please add more details.
    – LPChip
    Nov 15 '18 at 15:40
  • Just like in the answer provided below i expected the index.bat file to be run at start up or at login and see a command line windows running. But instead nothing happens. As if the task does not exist when i see that it does. there no errors. maybe it's a misconfiguration. Nov 15 '18 at 16:32
  • 1
    Are you sure it's not being run? Can you ECHO to a log file just to see if anything is written to it? If you selected "Run whether user is logged in or not", it may be running in the background with no visible command prompt window. If there is an error in the node command, it would also just flash a window for a moment and that might be too fast to see.
    – Worthwelle
    Nov 15 '18 at 17:15
  • I know the process has not run because the node js express server isn't running. Now if I double click on it the command line window opens and the node js express server starts up on port 80 Nov 15 '18 at 17:58
  • Why not just open a file explorer, go to shell:startup and make a shortcut to your index.bat file there? That will also work, but does require the user to be logged in, something that may be a requirement for this anyway.
    – LPChip
    Nov 16 '18 at 7:58

Do the following:

  1. Open Task Scheduler from the start menu

  2. From the menu, Action > Create task...

  3. Under the General tab, give it a name, an optional description, and choose the security options.

  4. Under the Triggers tab, add a new one, and select At startup from the Begin the task drop-down menu.

  5. Under the Actions tab, add a new one, choose Start a program as the action, browse to your batch file, and select it. Specify optional arguments, and in the Start in: dialogue, type the directory in which the batch file is located.

  6. Configure the conditions under which the file should run in the Conditions tab, and do the same in the Settings tab.

  7. That's it, you're done! Have fun!

  • Alternatively, you can also just set node.exe to run on startup in the same manner, and set <path-to-file>\index.js as your argument.
    – undo
    Nov 15 '18 at 15:08
  • 1
    I tried all of that and nothing happens. i think it might have to do with windows environment variables path to bash or cmd. maybe i didn't set the path correctly? Nov 15 '18 at 16:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.