Reputation: 937
I am trying to create an instance of a windows cmd terminal from powershell every minute for a maximum of 8 times and get each cmd instance to run a nodejs script from there.
Here is my code so far:
For ($i=0; $i -le 8; $i++) {
start cmd.exe /k node index.js
Start-Sleep -Seconds 60
}
but I keep on getting errors:
Start-Process : A positional parameter cannot be found that accepts argument 'node'.
At C:\Users\user\Documents\x\x\build\src\start.ps1:2 char:5
+ start cmd.exe /k node index.js
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
I have already looked at this answer posted on SuperUser, however, it is not clear to me what I am doing wrong.
The second answer on this stack overflow thread seems to be doing exactly what I am trying to do, but I keep getting the above error.
Upvotes: 0
Views: 261
Reputation: 255
Start is an alias for the Start-Process cmdlet as mentioned by @lit
Any arguments have to passed on with the -ArgumentList parameter.
start "cmd.exe" -ArgumentList "/k node index.js"
Upvotes: 2