0
subprocess.run([program,'-force-gfx-jobs native -token='+PHPSESSID+ ' -config={"BackendURL":"https://prod.app.com","Version","live"}'])

When this command is run and you took in task manager at the command line values passed to the program the double quotes are prefixed by backslashes like this

subprocess.run([program,'-force-gfx-jobs native -token='+PHPSESSID+ ' -config={\"BackendURL\":\"https://prod.app.com\",\"Version\",\"live\"}'])

1 Answer 1

1

You are passing a single string where you should be passing a list of strings.

subprocess.run([program,'-force-gfx-jobs', 'native',
     '-token='+PHPSESSID, '-config={"BackendURL":"https://prod.app.com","Version","live"}'])

I don't think the displayed backslashes are a problem; they are just for disambiguation (but this is Windows, so I'm probably underestimating the amount of crazy).

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

2 Comments

In Windows, every process has to parse its own command line string into arguments, i.e. there is no equivalent of a Unix argv array at the OS level. But there are standard argument parsing rules at least that are used by the Windows C runtime library and CommandLineToArgvW. When subprocess args is a list, subprocess.list2cmdline is called to build WinAPI CreateProcessW lpCommandLine according to these rules, including escaping literal double quote characters.
If you already have a command line that's prepared according to these rules, or if you need to pass a command line to a process that uses different rules (e.g. Cygwin programs follow Unix shell rules), then it makes more sense in Windows to simply pass subprocess args as a string. Don't try to manually parse the command line into a list just to have subprocess.list2cmdline rebuild it, potentially in a way that won't work.

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.