How to run a .bat file on a node server?
NickName:Salvatore Raccardi Ask DateTime:2019-01-20T04:43:49

How to run a .bat file on a node server?

I was wondering if you can perform an automatic restart of a server made with node. My idea was to run a .bat file via node that rebooted the server. It's possible to do it?

Copyright Notice:Content Author:「Salvatore Raccardi」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54271232/how-to-run-a-bat-file-on-a-node-server

Answers
Rami ZK 2019-01-19T20:50:39

You can use exec as follows \n\nconst { exec } = require('child_process');\nexec('shutdown -s -t 0') ; // change command according to your system \n\n\ncheck this question for more details on exec \n\nExecute a command line binary with Node.js",


More about “How to run a .bat file on a node server?” related questions

How to run a .bat file on a node server?

I was wondering if you can perform an automatic restart of a server made with node. My idea was to run a .bat file via node that rebooted the server. It's possible to do it?

Show Detail

Run node server with a bat file

I need to create a bat file to start node server, actually we do it manually but some people need extra help. Let me explain the process: Open CMD Go to the path: cd C://user/folder/server/ Run the

Show Detail

create a bat file to run node commands

I'm trying to run node commands like npm install and node server.js using a bat file. I'm planning to put the bat file in the application root folder. So, the steps I want my bat file to do are: O...

Show Detail

Start node server with .bat file

I want to start a node server with a .bat file, because everytime I start it, a grunt task has to be run. I tried the following lines in the start.bat: grunt build node index.js When I execute it...

Show Detail

restart node.js server from bat file

I'm trying to restart a node.js server without any thrid party library. The bat file is executed from the node server itself. Here is the restart.bat file: set processId=%1 taskkill /F /PID %proc...

Show Detail

How to run .bat file on unix server

I am not able to run ".bat" file on Unix server I have run following command to run that ".bat" file. sh Run.bat where Run.bat is ".bat" file. It gives me following error Invalid file

Show Detail

How do I run a .bat file for commands to execute in a second .bat file running a .jar?

Hey community I need to know how I can run .bat file to eacute a string of text to a .bat file running a .jar to use the command. also the batch file to run the command in the other batch file wil...

Show Detail

Run multiple bat files in one bat file server 2012

I have a simple app that I need to run on my servers. I need to run it independently on each drive of the server. I have a simple bat file that runs great on server 2008, but just flys through it o...

Show Detail

How to run batch (.bat) file from Spring server

I would like to run a bat file from my Spring server. I already have a method in my client, but I want to run the bat on my server. How can I do this? Edit: My intention was to upload a batch file

Show Detail

Unable to run a .bat file in java program

Problem Statement: I just want to start the HUB and Node to perform some tests using Selenium Grid. I have two Batch files START HUB.bat and START NODE.bat which run perfectly when i manually run t...

Show Detail