-3

i must write a batch file which changes the directory and than I want to start a command in this directory. It is a curl command like "curl --help"

what I have now is =

start cmd /K "cd C:\Users\myname\mycurl"

its working fine. and now i want to runn this command from this directorty.

curl --help

Can somebody help me please

thanks

Relaxo
  • 43
  • 6
  • It isn't clear what you are trying to achieve. The command you have reported as working fine is not correct, I would suggest that this should read, `START "" CMD /K "CD C:\Users\myname\mycurl"`. That said if there really was a need for `START` then using it's **`/D`** option may also help, `START "" /D "%UserProfile%\mycurl" CMD /K`; _(if you don't wish to open a new cmd window then add the **`/B`** option, `START "" /B /D "%UserProfile%\mycurl" CMD /K`)_. To directly run the command you have asked about you can add it to the end thus: `START "" /D "%UserProfile%\mycurl" CMD /K "curl --help"`. – Compo Jun 17 '17 at 13:29

2 Answers2

1

There is no use in having a batch starting another cmd with /K to stay open and then issue a command which fills more than a screen forcing to scroll back.

Either:

  • Open a cmd window and invoke C:\Users\myname\mycurl\curl.exe --help|more to read screen by screen - or
  • C:\Users\myname\mycurl\curl.exe --help|clip to copy the help to the clipboard and then paste to your preferred editor.
  • Read the curl manual online
-1
  1. A simple approach would be:

    start cmd /K "cd C:\Users\myname\mycurl && curl --help"

Using command1 && command2: you can execute command2 only if command1 succeeds.

Also refer: combining commands in DOS/windows

  1. You may also write a batch files with multiple commands. And invoke that batch file from the new command prompt.

Example: bat1.bat

start cmd /K "bat2.bat"

bat2.bat

echo running bat2.bat
cd C:\Users\myname\mycurl
curl --help
nihcash
  • 29
  • 3