Reputation: 1024
Learning how to use powershell. But what I am trying to do is from a specific location open a command prompt then execute a command.
So far I've been able to set the location and open the command prompt but can not run a command
so far i've tried this
Set-Location "F:\Projects\GameManagement\server"
start cmd.exe
And I've also tried the start process but dont know how to set the location and open with a specific program
The command i am trying to send to the command prompt is 'nodemon index.js'. Any suggestions?
Thanks
Upvotes: 1
Views: 717
Reputation: 437663
Like cmd.exe
, PowerShell is a shell, which means that you can invoke console applications directly, which executes them synchronously:
Set-Location F:\Projects\GameManagement\server
nodemon index.js
If the nodemon
executable too is located in F:\Projects\GameManagement\server
, you must replace the last line with
.\nodemon index.js
, as Robert Cotterman points out, because, PowerShell, unlike cmd.exe
, does not permit invocation of executables located in the current directory by name only, for security reasons.
From within PowerShell there is rarely a need to call cmd.exe
- just use PowerShell itself.
Upvotes: 1