I have the following command: cd ../../game ^ electron src that I need to run.

Which basically means step up two folders from our current directory then into the game folder and call electron on the src folder.

However it sees the electron src command as part of the cd command... and gives the error can't find the path specified

How can I break it up? so put the electron src AFTER the cd command.

This command gets executed inside a NodeJS application like:

exec('cd ../../game ^ electron src', function(...

As you can see I have tried the ^ to break it up but that doesn't seem to solve the problem... I have tried the same code in a Windows command prompt and it happens there so it's not because of the way NodeJS executes it.

  • Can you just give it the full path? C:/folder/folder/game electron src
    – CharlieRB
    Jul 2, 2015 at 15:19
  • No because it still says it can't find the path specified.
    – Cameron
    Jul 2, 2015 at 15:23
  • 1
    @CloseVoter, questions about using commands in the windows command line or batch files are on topic here.
    – DavidPostill
    Jul 2, 2015 at 15:30
  • @Cameron, please could you tag this Windows or Unix/Mac/Linux, and say clearly in the question which OS you're on? It makes a significant difference to the answer on command-line questions.
    – GKFX
    Jul 2, 2015 at 15:37

1 Answer 1


How do I run one command then run another?

Use the following command:

cd ../../game & electron src

The & means run the first command then run the second.

If you think the first command might fail then use && instead.

What is the syntax for command redirection?

  • command > filename Redirect command output to a file

  • command >> filename APPEND into a file

  • command < filename Type a text file and pass the text to command

  • commandA | commandB Pipe the output from commandA into commandB

  • commandA & commandB Run commandA and then run commandB

  • commandA && commandB Run commandA, if it succeeds then run commandB

  • commandA || commandB Run commandA, if it fails then run commandB

Source Redirection

Further reading

An A-Z Index of the Windows CMD command line is an excellent reference for all things Windows cmd line related.

  • This works fine in the command prompt but for some reason in NodeJs it just forgets the cd immediately after the & and calls electron in the current directory we are in...
    – Cameron
    Jul 2, 2015 at 15:37
  • Does the same thing... calls electron in the same directory we are running the script inside...
    – Cameron
    Jul 2, 2015 at 15:44
  • Neither really, so I have just called the exe directly using a different method. Seems that the electron command has issues with the cd when used inside NodeJS. Accepted answer as the & was the best solution outside of Node :P
    – Cameron
    Jul 2, 2015 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.