0

I need to open lnk file with arguments via Python. On the command line it looks like this:

FlashProgrammer -target=arm image.elf -device=xxxx -vdd=3V3 -erase=mass -program - secure

And it works. But how can I do this in Python? I tried something with subprocess, but got an error: OSError: [WinError 193] %1 is not a valid Win32 application. I think it is due of file extension.

Example code:

import subprocess

flash_programmer_path = "FlashProgrammer.lnk"

args = "FlashProgrammer -target=arm image.elf -device=xxxxx -vdd=3V3 -erase=mass -program - secure"

subprocess.run([flash_programmer_path, args])

Instead of subprocess.run I tried to use subprocess.call giving the same arguments as in the console. However, that doesn't work either.

1
  • @martineau added Commented May 27, 2021 at 7:31

1 Answer 1

0

I should use os.system(args). Then it works. Case closed.

Your Answer

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

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