0

I'm trying to write a bit of code to allow me to open up an exe file within Python, but I don't know the general way to make it properly. I would think that the code would look something like this:

exec(open("C:\\Users\\user\\AppData\\Local\\Programs\\file-folder\\file.exe").read())

but when I compile the code using Geany, it gives me an error saying UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2: character maps to undefined

I get the same error message when I try to write the file path with just one \ between each folder, but it gives me the same error in the compiler. Any help on this is greatly appreciated.

2 Answers 2

2

you can use subprocess.call:

import subprocess
subprocess.call(["fullPath\\yourExe.exe"])
Sign up to request clarification or add additional context in comments.

Comments

1

well you need to import os in your code if you wanna execute external files

import os
os.startfile(""C:\\Users\\user\\AppData\\Local\\Programs\\file-folder\\file.exe"")

1 Comment

This does the trick too, however, if the program produces any output then usually os.startfile is not recommended, unlike subprocess.call where it only continues when the output has been produced

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.