0

I just want to start a curl command in a minimized console.

this works:

START "" /B /W curl -X POST https://someurl.com -d "url_parameters_for_curl" > output.txt

But this does not work

START "" /MIN /W curl -X POST https://someurl.com -d "url_parameters_for_curl" > output.txt

I think it has something to do with the double quotes. I tried multiple escaping characters like ^ or "" and triple """ which worked for some other programs but START does not seem to be able to escape the double quotes when opening a new console window...

I've spent like 2 hours now trying to figure this out and I have no idea what to do.

PS: putting the command in a .bat file and calling it with

START /MIN /W mybat.bat

is working. But the command is generated on the fly and I don't want to write a file each time.

PPS: the command is spawned by a background process without a console window which leads to a console window popping up every time this happens. I just wanted it to appear minimized.

EDIT:

The hint with escaping the

> output.xml

with

^> output.xml  OR ^>output.xml

did not work. But curl has an option to write the output to a file. So this finally worked:

START "" /MIN /W curl -X POST https://someurl.com -d "url_parameters_for_curl" -o output.txt

The question remains: How would you escape the "> outputfile" using the START command?

2
  • 2
    What do you mean by "it doesn't work"? please be precise! the double-quotes shouldn't be a problem, maybe you even need more of them around the URL… Commented Dec 14, 2020 at 15:00
  • I agree: the quotes shouldn't be a problem. I guess your output.txt is empty? You redirect the output of the start command - which is empty. Escape the > to pass it to the started process: ...^>output.txt Commented Dec 14, 2020 at 15:04

1 Answer 1

1

I would say, because curl.exe is a CLI process, that it isn't cURL you need to minimize, but the cmd.exe window it spawns to run within.

For that reason, I'd offer:

Start /Min /W %SystemRoot%\System32\cmd.exe /D/Q/C "%SystemRoot%\System32\curl.exe -X POST https://someurl.com -d "url_parameters_for_curl" 1> "output.txt" 2>&1"

In the example above, I've also redirected StdErr to the file, (because you wouldn't see that, in a minimized window). If you don't want that, you can remove 2>&1 from above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.