There was a requirement that I need to start the Node.js server from a C # application, it is as simple as running a server.jsscript in the Node.js console. However, I'm not quite sure how to achieve this.
Here is what I have learned so far:
There is a file called Node.js in the installation C:\Program Files (x86)\nodejs\nodevars.bat; this is a command-line window for Node.js. To start the server, I could follow these steps:
- Execute the file
nodevars.bat. SendKeys into a new process console window to start the server.
This approach seems a bit fragile. There is no guarantee that the target user will have their Node.js installation in the same place, also sending keys to the process may not be the ideal solution.
Another way could be:
- Write a batch file that executes
nodevars.bat. - Run the batch file from a C # application.
This seems like the best approach, however the only problem is what nodevars.batopens in a new console window.
So, to the question (s), is there a way to start the Node.js script server using the functionality built into the Node.js installation? Perhaps sending arguments to node.exe?
source
share