Windows can automatically run nodejs application in the background through VBS + bat

Time:2021-12-6

Environment: Windows 8.1

The principle is to run bat files through VBS windowless background

1. Create a new. Bat file. The contents are as follows:

?
1
2
3
4
@ECHO ON 
f:
cd \repositories\yyper
start /b nodemon index.js -f

2. Create a new. VBS file. The contents are as follows:

?
1
2
Set ws = CreateObject("Wscript.Shell"
ws.run "cmd /c run-yyper-blog.bat",vbhide

Double click the. VBS file. I start nodejs app test through this method. Multiple double clicks will start multiple nodejs processes. However, if you start it manually through the GIT client, if you have started it once, you will not start it again because the port is occupied. It’s strange. Who can tell me why, please leave a message

PS: the method of adding startup and self startup software to win8 system (found online, not tested)
Copy the shortcut of the software that needs to be set to start automatically to any path below
The startup path is as follows:

?
1
2
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
C: \ users \ your user name \ appdata \ roaming \ Microsoft \ windows \ start menu \ programs \ startup