1
LYX_EXE = r'"c:\Program Files (x86)\LyX 2.3\bin\LyX2.3.exe"' process = subprocess.Popen(LYX_EXE) 

This works - the program loads.

LYX_EXE = r'"c:\Program Files (x86)\LyX 2.3\bin\LyX2.3.exe"' process = subprocess.Popen([LYX_EXE]) 

This fails: I get "PermissionError: [WinError 5] Access is denied".

What did I do wrong? I need the second call type since I want to use parameters.

1 Answer 1

1

I think in the second call type you have to avoid the quoting (Since it's already in a list, the executable and arguments are already separated):

LYX_EXE = r"c:\Program Files (x86)\LyX 2.3\bin\LyX2.3.exe" process = subprocess.Popen([LYX_EXE]) 

See also: https://docs.python.org/2/library/subprocess.html#converting-argument-sequence

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

1 Comment

To clarify, on Windows an args list gets joined back into a command line, which gets passed to WinAPI CreateProcess. subprocess uses the VC++ argv and WinAPI CommandLineToArgvW rules, which are how most programs consume their command line, with notable exceptions such as the CMD shell.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.