If i place into bat-file command to start node
wmic process call create "npm run go","%~dp0."
everything works fine:
D:\Temp\Supertemp\wmic npm>wmic process call create "node go","D:\Temp\Supertemp\wmic npm\."
Идет выполнение (Win32_Process)->Create()
Метод успешно вызван.
Параметры вывода:
instance of __PARAMETERS
{
ProcessId = 13292;
ReturnValue = 0;
};
But if I use npm
instead
wmic process call create "npm run go","%~dp0."
error 9 occurs, which according to msdn msdn means that path is not found:
D:\Temp\Supertemp\wmic npm>wmic process call create "npm run go","D:\Temp\Supertemp\wmic npm\."
Идет выполнение (Win32_Process)->Create()
Метод успешно вызван.
Параметры вывода:
instance of __PARAMETERS
{
ReturnValue = 9;
};
File package.json
:
{
"name": "wmic-npm-test",
"version": "0.0.0",
"scripts": {
"go": "node go"
}
}
File go.js
:
setInterval(function () {
console.log(require('process').cwd());
}, 1000);
If simply start npm
from console, everything works:
D:\Temp\Supertemp\wmic npm>npm run go
> wmic-npm-test@0.0.0 go D:\Temp\Supertemp\wmic npm
> node go
D:\Temp\Supertemp\wmic npm
D:\Temp\Supertemp\wmic npm
I'm starting it via wmic
to get process id.
There file npm.cmd
and npm
file for sh
:
D:\Temp\Supertemp\wmic npm>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
To execute npm
command you need to specify that you want to run cmd-file:
wmic process call create "npm.cmd run go","%~dp0."