2
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?
2
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
Do the following:
Open Task Scheduler from the start menu
From the menu, Action
> Create task...
Under the General
tab, give it a name, an optional description, and choose the security options.
Under the Triggers
tab, add a new one, and select At startup
from the Begin the task
drop-down menu.
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.
Configure the conditions under which the file should run in the Conditions
tab, and do the same in the Settings
tab.
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. – rahuldottech – 2018-11-15T15:08:58.573
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? – jehovahsays – 2018-11-15T16:37:40.570
1When you say, does not work as expected, what does and what does not work? Please add more details. – LPChip – 2018-11-15T15:40:47.620
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. – jehovahsays – 2018-11-15T16:32:33.747
1Are 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 thenode
command, it would also just flash a window for a moment and that might be too fast to see. – Worthwelle – 2018-11-15T17:15:13.167I 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 – jehovahsays – 2018-11-15T17:58:56.667
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 – 2018-11-16T07:58:16.330